我不是試圖畫一個組件,我只是試圖創建一個新的上下文(我認爲),並吐出一個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