我有一个 UIView,其中有多个 UIImageView 作为 subview 。每个 subview 都应用了不同的仿射变换。我想截取 UIView 的屏幕截图,将其捕获为 UIImage 或其他一些图像表示形式。
我已经尝试过的方法,将图层渲染到 CGContext:
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
不保留 subview 的定位或其他仿射变换。
我真的很感激能朝正确的方向踢一脚。
最佳答案
试试这个:
UIGraphicsBeginImageContext(self.view.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
关于iphone - 将 UIViews subview 展平为 UIImage iPhone 3.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1424566/