📜  swift uiview 渐变 - Swift 代码示例

📅  最后修改于: 2022-03-11 15:00:58.934000             🧑  作者: Mango

代码示例1
let view = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 50))
let gradient = CAGradientLayer()

gradient.frame = view.bounds
gradient.colors = [UIColor.white.cgColor, UIColor.black.cgColor]

view.layer.insertSublayer(gradient, at: 0)