Hi, I am trying to create my own cropping tool that allows the user to create a custom enclosed area using the bezier path.

The code that I use for the imageView clip with an outline,
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = self.bounds; maskLayer.path = clippingPath.CGPath; [imgView.layer setMask:maskLayer];
but the result

Can someone point me in the right direction, what should I do?
-(void)longPressAddPoint:(UITapGestureRecognizer*)gesture { ctr++; CGPoint touchpoint=[gesture locationInView:self]; [ptsNew addObject:[NSValue valueWithCGPoint:[gesture locationInView:self] ]]; if(ctr>1) { if(CGRectContainsPoint([self viewWithTag:1].frame, [gesture locationInView:self])) { pathClosed=YES; touchpoint=[self viewWithTag:1].center; } UIView *greenCircle=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 20, 20)]; greenCircle.center=touchpoint; greenCircle.backgroundColor=[UIColor greenColor]; [greenCircle setTag:ctr]; [greenCircle.layer setCornerRadius:10]; [self addSubview:greenCircle]; [pathMain appendPath:[pathCurrent bezierPathByReversingPath]]; pathMain.usesEvenOddFillRule=YES; [pathCurrent moveToPoint:[[ptsNew objectAtIndex:ptsNew.count-2] CGPointValue]]; [pathCurrent addCurveToPoint:[[ptsNew objectAtIndex:ptsNew.count-1] CGPointValue] controlPoint1:firstControllPoint.center controlPoint2:[[ptsNew objectAtIndex:ptsNew.count-1] CGPointValue]];
I have a main path (which is passed as a clipping path). I create the current path to which the user can add a curve. When the user adds a new path, the current path is added to the main path.
source share