码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 贝赛尔 圆形进度条

时间:2015-04-13 01:35:14      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

    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];

 

iOS 贝赛尔 圆形进度条

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!