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