CoreGraphics中:图像透明背景 [英] CoreGraphics: Image Transparent Background
本文介绍了CoreGraphics中:图像透明背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图用2px的透明边框绘制图像:
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?
解决了,我在其中设置图像的UIImageView的只是黑色的背景=(以上code ++工程!
Solved, the uiimageview in which I set the image was simply black background =( The above code works!
推荐答案
解决了,我在其中设置图像的UIImageView的只是黑色的背景=(以上code ++工程!
Solved, the uiimageview in which I set the image was simply black background =( The above code works!
这篇关于CoreGraphics中:图像透明背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文