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的隐式动画

 

转载于:https://www.cnblogs.com/oumygade/p/4455521.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值