【发布时间】:2016-09-23 18:12:49
【问题描述】:
我有一个 UIView,里面有另一个 UIView 和一个 UIImageView。我想将 UIImage 展平到 UIView 上。如果有帮助,您可以考虑这样的布局:
-UIView
---UIImageView
---UIView
如何捕获整个 UIView 并将其保存为单个图像?
【问题讨论】:
标签: ios objective-c cocoa-touch
我有一个 UIView,里面有另一个 UIView 和一个 UIImageView。我想将 UIImage 展平到 UIView 上。如果有帮助,您可以考虑这样的布局:
-UIView
---UIImageView
---UIView
如何捕获整个 UIView 并将其保存为单个图像?
【问题讨论】:
标签: ios objective-c cocoa-touch
您可以使用它来将您的视图保存为单个图像。
-(UIImage *)visibleImage
{
UIGraphicsBeginImageContextWithOptions(yourview.frame.size, YES, [UIScreen mainScreen].scale);
CGContextTranslateCTM(UIGraphicsGetCurrentContext(), CGRectGetMinX(yourview.frame) , CGRectGetMinY(yourview.frame));
[yourview.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *img_FinalVisible = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img_FinalVisible;
}
【讨论】: