[IOS]如何画一个圆环

参考:http://blog.csdn.net/u013282507/article/details/50247001

-(void)initCircle{
    CAShapeLayer *layer = [CAShapeLayer new];
    layer.lineWidth = 2;
    //圆环的颜色
    layer.strokeColor = [UIColor blackColor].CGColor;
    //背景填充色
    layer.fillColor = [UIColor clearColor].CGColor;
    //设置半径为10
    CGFloat radius = circle_radius;
    //按照顺时针方向
    BOOL clockWise = false;
    //初始化一个路径
    UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:self.view.center radius:radius startAngle:0 endAngle:2.0f*M_PI clockwise:clockWise];
    layer.path = [path CGPath];
    [self.view.layer addSublayer:layer];
}

猜你喜欢

转载自jameskaron.iteye.com/blog/2397423