iOS 熟悉CASharpLayer
1. 代码示例
- (void)viewDidLoad {
[super viewDidLoad];
CAShapeLayer *shape = [CAShapeLayer layer];
UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(100, 100, 200, 200) cornerRadius:98];
shape.path = bezierPath.CGPath;
shape.fillColor = [UIColor clearColor].CGColor;
shape.strokeColor = [UIColor blueColor].CGColor;
shape.lineWidth = 4.f;
shape.strokeStart = 0.f;
shape.strokeEnd = 0.7f;
[self.view.layer addSublayer:shape];
self.shape = shape;
}
- (IBAction)btn:(id)sender {
CGFloat text = (arc4random()%100)/100.f;
NSLog(@"====%f",text);
self.shape.strokeStart = text;
}
2. 顶部端是strokeStart,左下端是strokeEnd
2.1. 当strokeStart>strokeEnd,shapeLayer无法显示
2.2. strokeStart,strokeEnd的取值范围都再0-1之间,包含0,1
2.3. 改变strokeStart或strokeEnd,会触发shapeLayer的隐式动画
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。