我要在UIView中画一个简单的圆形。我不想用QuartzCore,能不能用drawRect实现?
- (void)drawRect:(CGRect)rect
{
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextAddEllipseInRect(ctx, rect);
CGContextSetFillColor(ctx, CGColorGetComponents([[UIColor greenColor] CGColor]));
CGContextFillPath(ctx);
}
上述代码在设置[UIColor whiteColor]
时就不工作。在设置了[UIColor whiteColor],视图就变成了透明的。
为什么设置白色但是视图变透明?怎么样画圈?