美文网首页
iOS 将UIView控件转换成UIImage对象

iOS 将UIView控件转换成UIImage对象

作者: Bytesking | 来源:发表于2017-09-29 09:55 被阅读0次

源码地址:前去查看链接

/**
 将 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;
}

相关文章

网友评论

      本文标题:iOS 将UIView控件转换成UIImage对象

      本文链接:https://www.haomeiwen.com/subject/ebgbextx.html