-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 に答える