美文网首页iOS Development
Swift ----- 渐变颜色

Swift ----- 渐变颜色

作者: 71150ce14a00 | 来源:发表于2017-04-06 15:31 被阅读18次
    let view = UIView(frame: .init(x: 10, y: 100, width: 200, height: 100))
    self.view.addSubview(view)
    
    
    let gradientLayer = CAGradientLayer()
    gradientLayer.frame = view.frame
    gradientLayer.colors = [UIColor.red.cgColor,UIColor.yellow.cgColor]
    gradientLayer.locations = [0.1,0.4]
    gradientLayer.startPoint = CGPoint(x: 0, y: 0)
    gradientLayer.endPoint = CGPoint(x: 1, y: 1)
    view.layer.addSublayer(gradientLayer)

相关文章

网友评论

本文标题:Swift ----- 渐变颜色

本文链接:https://www.haomeiwen.com/subject/urdqattx.html