【发布时间】:2011-11-29 16:22:27
【问题描述】:
我想从我的 iPhone 应用程序中截取我的视图屏幕。我有白色背景视图,并使用此方法在该视图的图层上画了一条线。
- (void)draw {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
if (self.fillColor) {
[self.fillColor setFill];
[self.path fill];
}
if (self.strokeColor) {
[self.strokeColor setStroke];
[self.path stroke];
}
CGContextRestoreGState(context);
}
- (void)drawRect:(CGRect)rect {
// Drawing code.
for (<Drawable> d in drawables) {
[d draw];
}
[delegate drawTemporary];
}
我使用委托方法在图层上画线。 这是我从中获得帮助的项目链接。 https://github.com/search?q=dudel&type=Everything&repo=&langOverride=&start_value=1
现在,当我使用以下上下文方法仅保存绘图时,我成功地保存了它而没有白色背景。
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
但是当我使用贝塞尔路径的以下方法时,我无法保存没有白色背景的绘图,它会保存整个屏幕,即该绘图及其背景。
UIGraphicsBeginImageContext(self.view.bounds.size);
[dudelView.layer renderInContext:UIGraphicsGetCurrentContext()];
//UIImage *finishedPic = UIGraphicsGetImageFromCurrentImageContext();
那么任何人都可以帮助我如何将绘图仅保存在此应用中。
【问题讨论】:
-
我也面临同样的问题
标签: ipad ios4 mkmapview mapkit core-location