1
 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 时。我得到一个在右侧和底部带有黑色边缘的图像。 在此处输入图像描述 我不知道为什么会出现黑边。为什么会出现这种情况以及如何避免这种情况?

4

0 回答 0