纯笔记类……希望喜欢:)
#import <QuartzCore/QuartzCore.h>
+ (UIImage *) imageWithView:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}支持视网膜:)
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);以上一段导致不支持透明背景( clear color),so,改成
UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, 0.0);可行

本文介绍了一种将iOS中的UIView转换为UIImage的方法,并讨论了如何调整以支持透明背景。
502

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



