【发布时间】:2014-04-14 10:23:18
【问题描述】:
我无法在另一个图像上绘制图像。下面是我使用的代码:
-(void)createImage
{
// create a new bitmap image context at the device resolution (retina/non-retina)
UIGraphicsBeginImageContextWithOptions(imgVw_noHair_.frame.size, YES, 0.0);
// get context
CGContextRef context = UIGraphicsGetCurrentContext();
// push context to make it current
// (need to do this manually because we are not drawing in a UIView)
UIGraphicsPushContext(context);
// drawing code comes here- look at CGContext reference
// for available operations
// this example draws the inputImage into the context
[eraser drawAtPoint:CGPointMake(50, 50)];
// pop context
UIGraphicsPopContext();
UIImage _image_ = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
我从当前上下文中获得的图像是黑色图像。我想在从上下文中获得的图像上绘制橡皮擦图像。
【问题讨论】:
-
你为什么要画它,你可以有imageview的权利..!!
-
你看看这个答案..stackoverflow.com/a/1480838/1865424
-
@Stark - 当我使用相同的代码而不是圆圈绘制图像时,会出现警告并且没有显示任何内容。
CGContextRestoreGState: invalid context 0x0
标签: ios objective-c iphone ios7 cgcontext