我不是试图画一个组件,我只是试图创建一个新的上下文(我认为),并吐出一个UIImage与我的绘图的内容。我没有试图利用任何现有的组件。我正在使用以下代码:iphone绘画背景
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL, self.textSize.width, self.textSize.height, 8, 4 * self.textSize.width,
colorSpace, kCGImageAlphaPremultipliedFirst);
CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 1);
NSString *text = @"Hello world";
[text drawAtPoint:CGPointMake(0, 0) forWidth:maxWidth withFont:font lineBreakMode:UILineBreakModeWordWrap];
CGImageRef imageMasked = CGBitmapContextCreateImage(context);
CGContextRelease(context);
CGColorSpaceRelease(colorSpace);
UIImage * myRendering = [UIImage imageWithCGImage:imageMasked];
不幸的是,我收到“无效的上下文”错误消息。搜索Google似乎只会引起人们试图利用现有组件。我想吐出一个新的UIImage。
我仍然得到:
:CGContextGetShouldSmoothFonts:无效的情况下 :CGContextSetFont:无效的情况下 :CGContextSetTextMatrix:无效的情况下 :CGContextSetFontSize:无效背景 等...
我只想绘制一个no context并返回一个我的绘图的UIImage ...可以这样做吗? – 2010-07-15 23:13:59
所以无论如何这里复制的代码:http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_context/dq_context.html#//apple_ref/doc/uid/TP30001066-CH203-SW9 看不到我怎么能得到它错了 - 仍然得到: 周五7月16日10时04分52秒MitchMac.local年鉴[75297]:CGContextGetShouldSmoothFonts:无效的情况下 –
2010-07-16 00:07:45