美文网首页
i0S-CAShaperLayer结合UIBezierPath画

i0S-CAShaperLayer结合UIBezierPath画

作者: weyan | 来源:发表于2018-03-09 16:19 被阅读0次

    实例:

    - (void)drawRoundView:(CGPoint)centerPoint withStartAngle:(CGFloat)startAngle withEndAngle:(CGFloat)endAngle withRadius:(CGFloat)radius {
        UIBezierPath *path = [UIBezierPath bezierPath];
        [path addArcWithCenter:centerPoint radius:radius startAngle:startAngle endAngle:endAngle  clockwise:YES];
        self.arcLayer = [CAShapeLayer layer];
        self.arcLayer.path = path.CGPath;
        self.arcLayer.strokeColor = [UIColor blueColor].CGColor;
        //arcLayer.strokeColor可设置画笔颜色
        self.arcLayer.lineWidth = 10;
        self.arcLayer.frame = self.view.bounds;
        self.arcLayer.fillColor = [UIColor clearColor].CGColor;
        [self.view.layer addSublayer:self.arcLayer];
        
    //    动画显示圆则调用
        [self drawLineAnimation:self.arcLayer];
    }
    
    - (void)drawLineAnimation:(CALayer*)layer {
        CABasicAnimation *bas = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
        bas.duration = 1;
        bas.fromValue = [NSNumber numberWithInteger:0];
        bas.toValue = [NSNumber numberWithInteger:1];
        [layer addAnimation:bas forKey:@"key"];
    }
    

    相关文章

      网友评论

          本文标题:i0S-CAShaperLayer结合UIBezierPath画

          本文链接:https://www.haomeiwen.com/subject/uexmfftx.html