-(UIImage*)convertViewToImage:(UIView*)v{
UIGraphicsBeginImageContext(v.bounds.size);
[v.layerrenderInContext:UIGraphicsGetCurrentContext()];
UIImage*image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
returnimage;
}
本文介绍如何将UIView转换为UIImage的方法,通过UIGraphics上下文和UIView层的渲染过程实现图像转换。
-(UIImage*)convertViewToImage:(UIView*)v{
UIGraphicsBeginImageContext(v.bounds.size);
[v.layerrenderInContext:UIGraphicsGetCurrentContext()];
UIImage*image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
returnimage;
}
78

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