我試圖繪製一個UIView一個簡單的圓形。我知道我可以QuartzCore做,但我想用drawRect方法:爲什麼顏色透明試圖繪製的drawRect一個彩色圓圈是什麼時候?
- (void)drawRect:(CGRect)rect
{
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextAddEllipseInRect(ctx, rect);
CGContextSetFillColor(ctx, CGColorGetComponents([[UIColor greenColor] CGColor]));
CGContextFillPath(ctx);
}
上面的代碼,當我設置[UIColor whiteColor]
不起作用。當[UIColor whiteColor]
視圖將成爲透明..
爲什麼視圖變得透明時,顏色是白色的?我如何繪製一個白色的圓圈?