【发布时间】:2013-07-23 10:02:50
【问题描述】:
我正在使用下面的代码在自定义 CALayer 类的 drawLayer 方法中绘制一条弧线,但没有显示任何内容:
(void) drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
float r = self.bounds.size.width/2;
CGContextClearRect(ctx, self.bounds); // clear layer
CGContextSetFillColorWithColor(ctx, [UIColor whiteColor].CGColor);
//CGContextFillRect(ctx, layer.bounds);
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(0, 0) radius:r startAngle:-M_PI_2 endAngle:M_PI_2 clockwise:NO];
CGContextAddPath(ctx, path.CGPath);
CGContextStrokePath(ctx);
}
请注意,如果我取消注释 CGContextFillRect(ctx, layer.bounds) 行,则会正确呈现一个矩形。
【问题讨论】:
-
缺少描边颜色?
标签: ios core-animation calayer quartz-graphics