您的位置:首页 > 产品设计 > UI/UE

IOS 将UIView转成UIImage

2012-12-13 12:06 387 查看
+(UIImage*) imageOfView:(UIView*) view isRetain:(BOOL)
retain{

float scale = 1.0;

if (retain == YES) {
scale =
2.0;
}

UIGraphicsBeginImageContextWithOptions(view.frame.size,
NO, scale);

[view.layer
renderInContext:UIGraphicsGetCurrentContext()];

UIImage *image =
UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return image;
}
很简单,当我们传入UIWindow的实例时,得到的图片即是我们的程序截图了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: