Soo*_*uNe 6 iphone cocoa-touch cgcontext
我有一个UIView,它有几个UIImageViews作为子视图.这些子视图中的每一个都应用了不同的仿射变换.我想采取相当于我的UIView的屏幕截图,将其捕获为UIImage或其他图像表示.
我已经尝试过的方法,将图层渲染为CGContext:
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
Run Code Online (Sandbox Code Playgroud)
不保留我的子视图的定位或其他仿射变换.
我真的很感激正确的方向踢.
Mar*_*don 11
试试这个:
UIGraphicsBeginImageContext(self.view.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)