如何将 UIView 转换为 UIImage? [英] How to convert UIView as UIImage?

查看:12
本文介绍了如何将 UIView 转换为 UIImage?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从 currentview 截取屏幕截图.但我想设置框架……不想将全视图转换为图像.我给出了框架大小……但它总是需要图片为全视图..有什么帮助吗?

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];

推荐答案

quartz 可能会帮助你...看看 从图像的一部分创建图像....它不是您问题的直接解决方案,但我认为您可以对其进行调整以满足您的需求..

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..

这篇关于如何将 UIView 转换为 UIImage?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆