I have a UIView with an image drawn in it. And I drawed a bezier path on the uiview, and I tried to mask the uiview according to the bezier path, it works but the mask get shifted down all the time.
Here are the images:
And I drew a bezier path on the view:
The final result, after I the apply mask is:
Here is what I tried:
-(void)sendBezierPath:(UIBezierPath *)path{
//this method gets hit after the bezier path gets interesected
_shapeLayer=[[CAShapeLayer alloc]init];
_shapeLayer.frame=imageUIView.frame;
_shapeLayer.path=path.CGPath;
imageUIView.layer.mask=_shapeLayer;
}
As you can see, I didn't give any position to the shape layer, but after the mask when I print the shape layer position, it gave me the value (160,294).
I can move the shape layer to get the current position,by
// shapeLayer.position=CGPointMake(160, 100);
but I want to know why it gets to the wrong position. It moved almost 40px down.