我想知道我的iPhone应用程序如何将一个特定的UIView
作为一个UIImage
进行截屏.
我试过这个代码,但我得到的只是一张空白图像.
UIGraphicsBeginImageContext(CGSizeMake(320,480));
CGContextRef context = UIGraphicsGetCurrentContext();
[myUIView.layer drawInContext:context];
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
myUIView
的尺寸为320x480,并且它有一些子视图.
做这件事的正确方法是什么?