-2

drawRect:单击方法中的颜色按钮时,我想更改方法中文本的​​颜色switchColor

这是我的代码:

- (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 ...请帮助我

4

1 回答 1

0

利用

CGContextSetFillColorWithColor(context, textColor);

于 2013-01-28T08:03:09.627 回答