UIGraphicsBeginImageContextWithOptions casue black edge

时间:2016-06-17 07:52:15

标签: ios uigraphicscontext cgcontextdrawimage

 UIGraphicsBeginImageContextWithOptions(size, YES,  [UIScreen mainScreen].scale);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
[[UIColor whiteColor] set];
CGContextFillRect(context, CGRectMake(0, 0, size.width, size.height));
CGContextRestoreGState(context);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;

我使用上面的代码生成图像。当我使用UIGraphicsBeginImageContextWithOptions(size, ***YES***, [UIScreen mainScreen].scale)时 并将opaque属性设置为YES。我得到一个右下角黑边的图像。 enter image description here 我不知道为什么会出现黑边。为什么会出现这种情况以及如何避免这种情况?

0 个答案:

没有答案