【问题标题】:Rendering button with CAGradientLayer使用 CAGradientLayer 渲染按钮
【发布时间】:2018-06-22 13:00:50
【问题描述】:

当我使用 CAGradientLayer 设置按钮时,它没有正确显示。

func setGradientBackground(color_A: UIColor, color_B: UIColor, indexLayer : Int){

    let granderLayer = CAGradientLayer()
    granderLayer.frame = bounds
    granderLayer.colors = [color_A.cgColor, color_B.cgColor]
    granderLayer.locations = [0.0, 1.0]
    granderLayer.startPoint = CGPoint(x: 1.0, y: 1.0)
    granderLayer.endPoint = CGPoint(x: 0.0, y: 0.0)

    layer.insertSublayer(granderLayer, at: UInt32(indexLayer))
}

在滚动后的 UITableView 的情况下,这是可行的

【问题讨论】:

    标签: swift xcode button


    【解决方案1】:

    您应该检查以下行中的边界值:“granderLayer.frame = bounds”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-25
      • 2011-04-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多