IOS set transparent border of path of cgcontext

597 Views Asked by At

I have added a bezier path to my context as follows

for (Face* face in facesArray) {

    UIBezierPath* customPath = [UIBezierPath bezierPath];
    [customPath moveToPoint:face.rightEyePosition];
    [customPath addQuadCurveToPoint:face.leftEyePosition controlPoint:face.foreheadPosition];
    [customPath addQuadCurveToPoint:face.mouthPosition controlPoint:face.lowerLeftContrlPoint];
    [customPath moveToPoint:face.rightEyePosition];
    [customPath addQuadCurveToPoint:face.mouthPosition controlPoint:face.lowerRightContrlPoint];

    UIGraphicsBeginImageContextWithOptions(originalImage.size, NO, 0.0);

    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextBeginPath (context);
    CGContextAddPath(context,customPath.CGPath);

    CGContextClosePath (context);
    CGContextClip (context);
    [imageView.image drawInRect: CGRectMake(0, 0, imageView.image.size.width, imageView.image.size.height)];

    UIImage* resultImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
}

Above code crops the image according to bezier shape. I want borders of cropped image transparent. How should I set transparency to corners ob bezier path

0

There are 0 best solutions below