3
drawInContext()를 재정의하고 내 CALayer 경계 외부로 그릴 수 있어야합니까? 내 레이어의 maskToBounds가 NO (기본값)로 설정되어 있어도 내 레이어의 경계로 설정된 클립으로 drawInContext()가 호출되고 그 바깥 쪽을 그릴 수 없습니다.왜 내 CGContext가 경계로 클리핑됩니까?
내 시험 층은 다음과 같이 수행합니다
-(void)drawInContext:(CGContextRef)context
{
[super drawInContext:context];
NSLog(@"mask to bounds=%d", self.masksToBounds); // NO
CGRect clip = CGContextGetClipBoundingBox(context);
NSLog(@"clip=%f,%f,%f,%f", clip.origin.x, clip.origin.y, clip.size.width, clip.size.height); // reports the bounds
CGContextSetStrokeColorWithColor(context, [[UIColor whiteColor] CGColor]);
CGContextBeginPath(context);
CGContextSetLineWidth(context, 5.0);
CGContextMoveToPoint(context, 0, 0);
CGContextAddLineToPoint(context, 500, 0.0); // wider than my layer...
CGContextStrokePath(context);
}
을 여기에 내가 그것을 설정하는 방법은 다음과 같습니다
- (void)viewDidLoad
{
[super viewDidLoad];
CALayer *layer = [[MyLayer alloc] init];
layer.needsDisplayOnBoundsChange=YES;
layer.frame = CGRectMake(50, 50, 200, 200);
[self.view.layer addSublayer:layer];
}
코어 애니메이션 레이어의 단지 제한이 있습니까? (이 레이어 위에 레이어를 그려야합니까?)
감사합니다.