2013-03-23 2 views
0

UITableViewCell의 배경보기를 내 자신의 사용자 정의 서브 클래스 UIView으로 바꿉니다. 여기서는 drawRect 메서드를 직접 재정의하여 여러 색상의 배경을 변경합니다.코어 그래픽 투명 오버레이

TableViewCell을 선택하면 아래의 그래픽이 완전히 숨겨져 이상하게 보입니다. 이 문제를 해결하기 위해 맞춤 selectedBackgroundView을 만들어야합니다. 문제는 해당 뷰가 이미 그 그래픽 위에 파란색 그라디언트 색조를 만들어야하며, 부분적으로 투명 한 CGRect 또는 비슷한 것을 그리는 방법을 모르겠습니다.

답변

2
// Write this In your - (void)drawRect:(CGRect)rect 
// To draw semi transparent Square 
// Create Current Context To Draw 
CGContextRef context = UIGraphicsGetCurrentContext(); 

UIBezierPath *square = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 100, 100)]; 
// following method will fill red color with alpha 0.4 last one in parameter list 
// first 3 are Red, Green and Blue Respectively. 
CGContextSetRGBFillColor(context, 1, 0, 0, 0.4); 
[square fill]; 
[square stroke];