//颜色渐变
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)
网友评论