我想UIImage从一个创建一个对象UIView.视图不是不透明的.因为我使用以下代码:
+ (UIImage *) imageWithView:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, [[UIScreen mainScreen] scale]);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
Run Code Online (Sandbox Code Playgroud)
但由于某些原因而不是透明背景我得到一个黑色背景的图像.我已经尝试将"opaque"参数设置UIGraphicsBeginImageContextWithOptions为NO但没有不同的结果.
有什么建议吗?
(类似问题CGContext透明度问题没有答案)