【发布时间】:2013-01-28 08:01:13
【问题描述】:
我想在我的switchColor 方法中单击颜色按钮时更改drawRect: 方法中文本的颜色。
这是我的代码:
- (void)drawRect:(CGRect)rect withColor:(UIColor*) color
{ CGContextRef 上下文 = UIGraphicsGetCurrentContext();
CGColorRef red = color.CGColor;
NSLog (@"color is %@",red);
//CGColorRef color = (__bridge CGColorRef)([UIColor colorWithRed:0.0 green:3.0 blue:2.0 alpha:1.0]);
CGContextFillRect(context, CGRectMake(130,200,120,120));
CGContextSetFillColorWithColor(context,red);
CGContextFillEllipseInRect(context, CGRectMake(130, 200, 120, 120));
}
错误 CGContextFillRects: 无效的上下文 0x0...请帮助我
【问题讨论】:
-
向我们展示一些您迄今为止尝试过的代码
-
我正在尝试使用 switchColor: 方法将按钮添加到视图中......请帮助我