【发布时间】:2014-09-23 10:25:04
【问题描述】:
我正在尝试使用 UIBezierPath addArcWithCenter 方法画一个圆:
UIBezierPath *bezierPath =
[UIBezierPath bezierPathWithOvalInRect:CGRectMake(0., 0., 100., 100.)];
[bezierPath addArcWithCenter:center
radius:0.
startAngle:0 endAngle:2 * M_PI clockwise:YES];
CAShapeLayer *progressLayer = [[CAShapeLayer alloc] init];
[progressLayer setPath:bezierPath.CGPath];
[progressLayer setStrokeColor:[UIColor colorWithWhite:1. alpha:.2].CGColor];
[progressLayer setFillColor:[UIColor clearColor].CGColor];
[progressLayer setLineWidth:.3 * self.bounds.size.width];
[progressLayer setStrokeStart:_volumeValue/100.];
[progressLayer setStrokeEnd:volume/100.]; // between 0 and 100
[_circleView.layer addSublayer:progressLayer];
但我得到的是以下内容:
我尝试使用不同的参数,但没有运气
谢谢
更新:
如果我没有解释我想要做什么,我很抱歉:
*背景圆是用 :
绘制的[UIBezierPath bezierPathWithOvalInRect:CGRectMake(0., 0., 100., 100.)]
*我正在尝试使用 bezierPathWithOvalInRect 逐步绘制红色圆圈 两个值之间:_volumeValue 和 volume
但我不能得到一个完美的圆,而是在一定值之后得到水平部分。
【问题讨论】:
-
哪个位不工作?对我来说,它看起来像一个圆圈。你能从图片中去除多余的“噪音”,只显示你感兴趣的东西吗?
-
另外,
volume和_volumeValue是什么? -
不清楚你想做什么。
-
好多了,我想我已经发现了。添加了答案。 :)
标签: objective-c calayer cashapelayer cabasicanimation