IOS图层Layer学习笔记(七)—— CAGradientLayer
来源:互联网 发布:cn 域名 编辑:程序博客网 时间:2024/05/30 04:25
简介
CAGradientLayer
是的CALayer
的子类,能够让颜色渐变填充。
填充的颜色是在backgroundColor
上面,子图层下面。
属性
colors
NSArray*, Animatable。渐变色数组,颜色必须是CGColorRef类型。默认nil。
// 光带效果UIColor *lucencyColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.2];UIColor *opaqueColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];_subLayer.colors = @[(__bridge id _Nullable)opaqueColor.CGColor, (__bridge id _Nullable)lucencyColor.CGColor, (__bridge id _Nullable)opaqueColor.CGColor];_subLayer.locations = @[@(0.3), @(0.5), @(0.7)];
locations
NSArray< NSNumber* >*, Animatable。与colors
对应的颜色分割位置。默认nil。
如果locations
为nil,则colors
的值在[0.0, 1.0]之间等分。
如果locations.count
小于colors.count
,则只能显示比locations.count
多1个colors
成员,并且最后一个colors
是在1.0位置。
如果locations.count
大于colors.count
,则locations
多余的位置全部显示colors
的最后一个成员。
成员数值有效范围为[0.0, 1.0],并且数组的值必须是递增的。具体位置需要根据startPoint
和endPoint
来判断。
虽然数组有效范围是[0.0, 1.0],但小于0.0和大于1.0的数值范围还是有一定作用的,比如某些动画效果:
// 一条光带不停的来回移动CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"locations"];animation.fromValue = @[@(-0.4), @(-0.2), @(-0.01)];animation.toValue = @[@(1.0), @(1.2), @(1.4)];animation.duration = 1.0;animation.autoreverses = YES;animation.repeatCount = FLT_MAX;[_subLayer addAnimation:animation forKey:nil];
startPoint
CGPoint, Animatable。层渐变绘制控制线起点。计算值。默认(0.5, 0.0).
endPoint
CGPoint, Animatable。层渐变绘制控制线起点。计算值。默认(0.5, 1.0).
type
NSString *,No Animatable。渐变样式。只有一个可选值。
NSString * const kCAGradientLayerAxial;
0 0
- IOS图层Layer学习笔记(七)—— CAGradientLayer
- IOS图层Layer学习笔记(二)—— CALayer(上)
- IOS图层Layer学习笔记(三)—— CALayer(下)
- IOS图层Layer学习笔记(二)—— CALayer(上)
- IOS图层Layer学习笔记(三)—— CALayer(下)
- IOS图层Layer学习笔记(一)—— 序
- IOS图层Layer学习笔记(四)—— CAShapeLayer
- IOS图层Layer学习笔记(五)—— CATextLayer
- IOS图层Layer学习笔记(六)—— CAScrollLayer
- IOS图层Layer学习笔记(一)—— 序
- IOS图层Layer学习笔记(四)—— CAShapeLayer
- IOS图层Layer学习笔记(五)—— CATextLayer
- iOS渐变图层CAGradientLayer
- CAGradientLayer(梯度图层)
- IOS 渐变的图层,CAGradientLayer
- iOS图层layer
- iOS UI——通过图层layer设置 图片的形变属性(transform)
- ios layer图层排序
- [leetcode] 84. Largest Rectangle in Histogram
- js 屏蔽页面右键功能、text、input框右键功能
- Opencv结构解析
- mysql报错注入(显错注入)整理
- ERROR: Cannot change version of project facet Dynamic Web Module to 3.0?
- IOS图层Layer学习笔记(七)—— CAGradientLayer
- oracle开启audit(审计)
- AndroidStudio更改字体颜色和大小
- UVA-1625 Color Length
- JQ---表格内容筛选
- IOU 设计模式介绍及应用
- Fragment的startActivityForResult详细解决方案
- WebKit(展示Web界面)
- iOS 中KVC、KVO、NSNotification、delegate 总结及区别