I need to move a layer by setting its frame, but without moving the clip of the layer.
I created a layer that is created as follows:
layer = [CustomLayer layer]; layer.frame = CGRectMake(50, 50, 100, 30); [layer setNeedsDisplay]; [self.view.layer addSublayer:layer];
And a clip layer, for example:
clipLayer = [CAShapeLayer layer]; UIBezierPath *clipPath = [UIBezierPath bezierPathWithRoundedRect:layer.bounds cornerRadius:10.0f]; clipLayer.path = clipPath.CGPath; layer.mask = clipLayer;
However, at some later point in my code, if I set the layer frame:
layer.frame = CGRectOffset(layer.frame, -20.0, 0.0);
Both layers and its clip mask are offset. The effect I'm trying to achieve is to “scroll” a layer under a rounded rectangular medium. Any ideas?
source share