2014-08-27 1 views
0

컷 아웃 마스크 염색 :나는 변경되지 않은 남아 원 영역 외부 화면 어두워 기능의 기초로이를 사용

Mask a UIView with a cut-out circle

하지만 내가하고 싶은 것은 선택적으로하는 것입니다 동그라미를 붉게하지만 모든 시도는 실패했습니다. 나는 어디로 잘못 가고 있니?

[[self fillColor] set]; 
UIRectFill(rect); 

CGContextRef context = UIGraphicsGetCurrentContext(); 
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect: self.circleFrame]; 
if (self.tintCircle) 
{ 
    float red[4] = {1,0,0,1}; 
    CGContextSetFillColor(context, red); 
    [path fill]; 
} 
else 
{ 
    [path fillWithBlendMode:kCGBlendModeDestinationOut alpha:1.0]; 
} 

답변

0

결국 꽤 쉬웠습니다. 나는 원을 잘라내어 다시 빨간색으로 그려야했습니다.

- (void)drawRect:(CGRect)rect 
{ 
    [[self fillColor] set]; 
    UIRectFill(rect); 

    UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect: self.circleFrame]; 
    [path fillWithBlendMode:kCGBlendModeDestinationOut alpha:1.0]; 

    if (self.drawRedCircle) 
    { 
     [[UIColor redColor] setFill]; 
     [path fillWithBlendMode:kCGBlendModeNormal alpha:0.5]; 
    } 
} 
관련 문제