Should I override drawInContext () and push outside my CALayer? Although my layer has maskToBounds set to NO (the default), my drawInContext () is called with a clip set to the borders of my layer, and I cannot paint outside of it.
My test layer does something like this:
-(void)drawInContext:(CGContextRef)context
{
[super drawInContext:context];
NSLog(@"mask to bounds=%d", self.masksToBounds);
CGRect clip = CGContextGetClipBoundingBox(context);
NSLog(@"clip=%f,%f,%f,%f", clip.origin.x, clip.origin.y, clip.size.width, clip.size.height);
CGContextSetStrokeColorWithColor(context, [[UIColor whiteColor] CGColor]);
CGContextBeginPath(context);
CGContextSetLineWidth(context, 5.0);
CGContextMoveToPoint(context, 0, 0);
CGContextAddLineToPoint(context, 500, 0.0);
CGContextStrokePath(context);
}
and here is how I installed it:
- (void)viewDidLoad
{
[super viewDidLoad];
CALayer *layer = [[MyLayer alloc] init];
layer.needsDisplayOnBoundsChange=YES;
layer.frame = CGRectMake(50, 50, 200, 200);
[self.view.layer addSublayer:layer];
}
Is this just a limitation of the main layers of animation? (Do I need to draw a layer above this layer?)
thank.
source
share