【发布时间】:2014-03-06 07:08:39
【问题描述】:
我尝试为给定的百分比值绘制一个圆(例如,如果我有 25%,我只画了四分之一的圆)。目前我只能在我的视野中画一个完整的圆圈。对我的问题有什么想法吗?
代码ATM:
- (UIBezierPath *)makeCircleAtLocation:(CGPoint)location radius:(CGFloat)radius
{
self.circleCenter = location;
self.circleRadius = radius;
UIBezierPath *path = [UIBezierPath bezierPath];
[path addArcWithCenter:self.circleCenter
radius:self.circleRadius
startAngle:0.0
endAngle:M_PI * 2.0
clockwise:YES];
return path;
}
- (void)drawCircleForLocation{
CGPoint location = CGPointZero;
location.x = self.frame.size.width/2;
location.y = self.frame.size.height/2;
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.path = [[self makeCircleAtLocation:location radius:9] CGPath];
shapeLayer.strokeColor = [[UIColor whiteColor] CGColor];
shapeLayer.fillColor = nil;
shapeLayer.lineWidth = 1.5;
[self.layer addSublayer:shapeLayer];
}
【问题讨论】:
标签: ios drawing uibezierpath cashapelayer