小编P.F*_*tus的帖子

UIView / 应用渐变时无法显示圆角半径

下面的代码在细节视图控制器中创建了一个带有渐变层的方形 UIView 框架。但是, square.layer.cornerRadius 不显示。它仍然是方形的。

    class Colors {
    let colorTop = UIColor(red: 68.0/255.0, green: 107.0/255.0, blue: 207.0/255, alpha: 1.0).cgColor
    let colorBottom = UIColor(red: 68.0/255.0, green: 108.0/255.0, blue: 179.0/255, alpha: 1.0).cgColor

    let gl: CAGradientLayer

    init() {
        gl = CAGradientLayer()
        gl.colors = [ colorTop, colorBottom]
        gl.locations = [ 0.0, 1.0]
     }
   }

 class DetailViewController: UIViewController {

 func viewWillAppear {
   let colors = Colors() // is a class that creates the gradient
   let square = UIView(frame: CGRect(x: 18, y: 109, width: 60, height: …
Run Code Online (Sandbox Code Playgroud)

ios swift3

2
推荐指数
1
解决办法
2283
查看次数

标签 统计

ios ×1

swift3 ×1