我有以下方法,我正在尝试对图像进行一些绘图:
- (UIImage*) renderImage
{
UIGraphicsBeginImageContextWithOptions(self.size, NO, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
//drawing code
UIImage *image = [UIGraphicsGetImageFromCurrentImageContext() retain];
UIGraphicsEndImageContext();
return [image autorelease];
}
当我运行这段代码时,我注意到我受到的打击比我简单地drawRect
在UIView
. 我是否在这里绘制了错误的图形上下文(即CGContextRef context = UIGraphicsGetCurrentContext();
)?还是UIGraphicsGetImageFromCurrentImageContext
只是比抽签贵得多drawRect
?