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