颜色透明渐变效果
CAGradientLayer *colorLayer = [CAGradientLayer layer];
colorLayer.frame = CGRectMake(0, 0, gradientView.frame.size.width, gradientView.frame.size.height);
[gradientView.layer addSublayer:colorLayer];
//添加渐变的颜色组合
colorLayer.colors = [NSArray arrayWithObjects:
(id)[[[UIColor clearColor] colorWithAlphaComponent:.0] CGColor],
(id)[[[UIColor clearColor] colorWithAlphaComponent:.1] CGColor],
(id)[[[UIColor clearColor] colorWithAlphaComponent:.2] CGColor],
(id)[[[UIColor clearColor] colorWithAlphaComponent:.3] CGColor],
(id)[[[UIColor clearColor] colorWithAlphaComponent:.4] CGColor],
(id)[[[UIColor clearColor] colorWithAlphaComponent:.5] CGColor],
(id)[[[UIColor clearColor] colorWithAlphaComponent:.6] CGColor],
(id)[[[UIColor clearColor] colorWithAlphaComponent:.7] CGColor],
nil];
参考链接:
UIView 的渐变色呈现
CAGradientLayer的一些属性解析
网友评论