UIGraphicsBeginImageContext(currentView.bounds.size);
[currentView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();解决模糊问题
CGSize size = CGSizeMake(SCREEN_WIDTH, 490);
UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
本文介绍了一种在iOS开发中实现视图清晰截图的方法。通过使用UIGraphicsBeginImageContextWithOptions并设置正确的尺寸及比例,确保了截图在不同分辨率设备上的清晰度。此技巧对于希望提高应用内截图质量的开发者非常实用。

892

被折叠的 条评论
为什么被折叠?



