CoreGraphics:图像透明背景
我正在尝试绘制一个带有 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 只是黑色背景 =( 上面的代码有效!
I am trying to draw an image with a 2px transparent border:
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();
It keeps getting black border (background)... =( Any ideas?
Solved, the uiimageview in which I set the image was simply black background =( The above code works!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决了,我设置图像的 uiimageview 只是黑色背景 =( 上面的代码有效!
Solved, the uiimageview in which I set the image was simply black background =( The above code works!