美文网首页
swift4.0 颜色渐变

swift4.0 颜色渐变

作者: 凄清肆水丶 | 来源:发表于2018-05-31 10:37 被阅读1次

 //颜色渐变

    functurquoiseColor() ->CAGradientLayer{

        lettopColor =UIColor.blue

        letbottomColor =UIColor.black

        letgradientColors:Array = [topColor.cgColor, bottomColor.cgColor]

        letgradientLocations:Array = [0.1asAnyObject,1.0asAnyObject]

        let gradientLayer: CAGradientLayer = CAGradientLayer()

        gradientLayer.colors= gradientColors

        gradientLayer.locations= gradientLocationsas? [NSNumber]

        returngradientLayer

    }

///调用

        letbackground =turquoiseColor()    

        background.frame=self.view.bounds

        self.view.layer.insertSublayer(background, at:0)

相关文章

网友评论

      本文标题:swift4.0 颜色渐变

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