Get UIBezierpath from UIImage Disguise

How can I get a UIBezierpath from a UIImage like this.

enter image description here

I do not need a full square path. I just want this path, as shown on the red border, from UIImage.

I went through link 1 and link 2 , but could not succeed.

I did the following code to get the masking path.

 CAShapeLayer *maskLayer = [CAShapeLayer layer]; maskLayer.frame = imgView.frame; UIBezierPath *roundedPath = [UIBezierPath bezierPathWithRoundedRect:maskLayer.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(50.f, 50.f)]; 

Basically, I want to get a UIBezierpath that follows the shape of alphabets such as A, B .. etc.

Please tell me is it possible or not to get this type of path?

Thanks in advance.

+6
source share
2 answers

For other users looking for answers, an alternative approach can be found here (using SVG as the source image file and PocketSVG to convert in the path)

0
source

Try this code:

 CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; pathAnimation.calculationMode = kCAAnimationPaced; pathAnimation.fillMode = kCAFillModeForwards; pathAnimation.removedOnCompletion = NO; pathAnimation.duration = 15.0; pathAnimation.repeatCount = 1; CGMutablePathRef curvedPath = CGPathCreateMutable(); CGPathMoveToPoint(curvedPath, NULL, x+15, y); CGPathAddQuadCurveToPoint(curvedPath, NULL, 20, 10, 100, 330); pathAnimation.path = curvedPath; CGPathRelease(curvedPath); Yourimage.center=CGPointMake(x, y); [Yourimage.layer addAnimation:pathAnimation forKey:@"moveTheSquare"]; 
-5
source

Source: https://habr.com/ru/post/916342/


All Articles