5
我动态创建上一个UITableViewCell的“UIImageView的”属性(绘制自己的定制)的UIImage。如何创建一个UIImage具有透明背景
当用户选择的tableView细胞,细胞背景将变为蓝色,但我定制的UIImage背景不 - 它仍然是白色的(所以很痛苦清楚我有一个像坐在那里)。我尝试了各种绘图方法
// when I create the cell
cell.imageView.backgroundColor = [UIColor clearColor];
cell.imageView.opaque = NO;
// 1. when I create the UIImage - clearColor background
CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
CGContextFillRect(context, rect);
// 2. when I create the UIImage - clear background
CGContextClearRect(context, rect);
但是在这两种方法中,背景都是黑色的。似乎工作的唯一方法是完成创建图像,然后应用基于第一个图像的'CGImageCreateWithMaskingColors'创建第二个图像 - 遮盖背景。
有什么办法,我可以“漆”摆在首位透明的背景是什么?
您是否在使用'UIGraphicsBeginImageContextWithOptions'来设置图片上下文?你是否在'opaque'参数中传递了'NO'? – rmaddy