background - CoreGraphics:图像透明背景

标签 background core-graphics transparent cgcontext

我正在尝试绘制具有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/

相关文章:

html - 鉴于此 Select 元素 CSS3 样式 : how to use Unicode character instead of background image?

objective-c - CGContextDrawImage 泄漏

css - 背景颜色在左侧和顶部的背景图像上产生

ios - 带圆角的UIBezierPath三角形

html - div 与父 div 的透明边框

android - 共享元素过渡在第一个 Activity 和第二个透明 Activity 之间留下奇怪的白色背景

wpf - 后台的 DataGridRow MultiDataTrigger : IsSelected condition not working

具有 2 种颜色的 CSS 背景会向两侧扩展?

html - 根据 ng-repeat 中的 $index 拆分一个 div 背景颜色

ios - 查找 CALayer 的边界框以绘制到图形上下文中