源码地址:前去查看链接
/**
将 UIView 转换成 UIImage
@param view 将要转换的View
@return 新生成的 UIImage 对象
*/
- (UIImage *)yj_convertCreateImageWithUIView:(UIView *)view{
UIGraphicsBeginImageContext(view.bounds.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[view.layer renderInContext:ctx];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
UIView转UIImage方法
本文介绍了一个简单的Objective-C方法,用于将UIView对象转换为UIImage。通过使用UIGraphicsBeginImageContext和view.layer.renderInContext方法,可以方便地实现这一转换。
73

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



