1
这个drawRect方法在我的iPhone应用程序自定义UIView类中出现了什么问题?它应该绘制一个彩色的圆圈,但它会绘制一个宽度和高度都适当的黑色方块。iPhone应用程序 - 为什么我的CGContext圈看起来像黑色方块?
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
UIColor *c = [UIColor redColor];
const CGFloat *components = CGColorGetComponents([c CGColor]);
CGFloat red = components[0];
CGFloat green = components[1];
CGFloat blue = components[2];
CGFloat al = components[3];
CGContextSetRGBFillColor(context, red, green, blue, al);
CGContextFillEllipseInRect(context, CGRectMake(x, y, width, width));
}