iOS 贝赛尔 圆形进度条

时间:2015-04-13 01:34:38   收藏:0   阅读:530

技术分享

    UIBezierPath *aPth = [UIBezierPath bezierPathWithArcCenter:CGPointMake(55, 65.f) radius:50.f startAngle:-M_PI_2 endAngle:M_PI_2 clockwise:YES];
    aPth.lineWidth = 5.0f;
    aPth.lineCapStyle = kCGLineCapRound;
    aPth.lineJoinStyle = kCGLineJoinRound;
    [[UIColor redColor] setStroke];
    [[UIColor orangeColor] setFill];
    [aPth stroke];

  

进度条动画


// 第一、 UIBezierPath 绘制线段

    UIBezierPath *circlePath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(55, 65.f) radius:50.f startAngle:-M_PI_2 endAngle:M_PI_2*3 clockwise:YES];

 

    // 第二、 UIBezierPath CAShapeLayer 关联

  CAShapeLayer *progressLayer = [ CAShapeLayer layer];

  progressLayer.path         = circlePath. CGPath ;

    progressLayer.fillColor     = [UIColor clearColor].CGColor;

  progressLayer.strokeColor   = [ UIColor redColor]. CGColor ;

  progressLayer.lineWidth     = 5.0f;

    progressLayer.lineCap      = kCALineCapRound;

 

    //第三,动画

    CABasicAnimation *ani = [ CABasicAnimation animationWithKeyPath : NSStringFromSelector ( @selector (strokeEnd))];

    ani. fromValue = @0 ;

  ani. toValue = @1 ;

 ani. duration = 5 ;
  [progressLayer addAnimation :ani forKey : NSStringFromSelector ( @selector (strokeEnd))];

 [view. layer addSublayer :progressLayer];

 

原文:http://www.cnblogs.com/binglin92/p/4421113.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!