如何将UIView转换为UIImage?
我正在从当前视图中获取屏幕截图图像。但我想设置框架......不想将全视图转换为图像。我给出了框架大小......但它总是需要 图片为全视图..有什么帮助吗?
CGRect rectt = CGRectMake(100, 150,150,200);
UIGraphicsBeginImageContext(rectt.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageView *imgView = [[UIImageView alloc] initWithFrame:rectt];
I am taking screenshot image from currentview.but i want to set frame….don't want to convert fullview as image.I gave frame size..but it takes always
Image as fullview..any help please?
CGRect rectt = CGRectMake(100, 150,150,200);
UIGraphicsBeginImageContext(rectt.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageView *imgView = [[UIImageView alloc] initWithFrame:rectt];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用此子类:
对于CaptureView.h,使用此文件代码
:
对于CaptureView.m:
try to use this subClass:
with this files code
for CaptureView.h:
for CaptureView.m:
石英可能会帮助你...看看从图像的一部分创建图像....
它不是您问题的直接解决方案,但我认为您可以对其进行调整以满足您的需求。
quartz might help you... look at creating image from part of image....
its not a direct solution to your question, but i think you'll be able to tweak it to fit your needs..