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