
代码如下:
#pragma mark -
#pragma mark UIVIEw helpers
@interface UIVIEw(Extended)
- (UIImage *) imageByRenderingVIEw;
@end
@implementation UIVIEw(Extended)
- (UIImage *) imageByRenderingVIEw {
CGfloat oldAlpha = self.Alpha;
self.Alpha = 1;
UIGraphicsBeginImageContext(self.bounds.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *resultingImage = UIGraphicsGetimageFromCurrentimageContext();
UIGraphicsEndImageContext();
self.Alpha = oldAlpha;
return resultingImage;
}
@end
但如果处理不好,这里截屏有时候速度会不太理想。 一个建议的解决方案是,让UIVIEw的layer采用CATiledLayer
CATiledLayer会很好的cache你的VIEw.
总结以上是内存溢出为你收集整理的UIView更快的截屏至UIImage(特别是ipad3) imageByRenderingView全部内容,希望文章能够帮你解决UIView更快的截屏至UIImage(特别是ipad3) imageByRenderingView所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)