【发布时间】:2011-01-13 23:18:09
【问题描述】:
我想知道我的 iPhone 应用如何将特定UIView 的屏幕截图作为UIImage。
我尝试了这段代码,但得到的只是一张空白图片。
UIGraphicsBeginImageContext(CGSizeMake(320,480));
CGContextRef context = UIGraphicsGetCurrentContext();
[myUIView.layer drawInContext:context];
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
myUIView 的尺寸为 320x480,并且有一些子视图。
这样做的正确方法是什么?
【问题讨论】:
标签: ios objective-c uiview screenshot