我正在尝试绘制具有2px透明边框的图像:
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 0.0);
CGContextAddRect(context, CGRectMake(0.0, 0.0, outputImageSize.width, outputImageSize.height));
CGContextDrawPath(context, kCGPathFill);
[image drawInRect:CGRectMake(2.0,
((outputImageSize.height - userPhotoImageSize.height) / 2.0) +2.0,
userPhotoImageSize.width -4.0,
userPhotoImageSize.height -4.0)];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
它不断得到黑色边框(背景)... =(有什么想法吗?
解决了,我在其中设置图像的uiimageview只是黑色背景=(上面的代码有效!
最佳答案
解决了,我在其中设置图像的uiimageview只是黑色背景=(上面的代码有效!
关于background - CoreGraphics:图像透明背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5593717/