码迷,mamicode.com
首页 > 其他好文 > 详细

画圆圈

时间:2014-12-17 22:41:18      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:ios

画圆圈

by 伍雪颖

CGPoint CGRectGetCenter(CGRect rect){
   
return CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect));
}
@interface ViewController () {
   
CAShapeLayer *circleLayer;
}
@property (nonatomic, strong) CADisplayLink *timer;
@end
@implementation ViewController

- (
void)viewDidLoad {
    [
super viewDidLoad];
   
circleLayer = [CAShapeLayer layer];
   
CGFloat radius = 30.0;
   
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGRectGetCenter(self.view.frame)
                                                       
radius:radius
                                                   
startAngle:-0.5 * M_PI
                                                     
endAngle:1.5 * M_PI
                                                    
clockwise:YES];
   
circleLayer.path = path.CGPath;
   
circleLayer.strokeColor = [UIColor redColor].CGColor;
   
circleLayer.lineWidth = 3;
   
circleLayer.fillColor = nil;
   
circleLayer.contentsScale = [UIScreen mainScreen].scale;
    [
self.view.layer addSublayer:circleLayer];
}

画圆圈

标签:ios

原文地址:http://blog.csdn.net/rainlesvio/article/details/41989247

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