6

How can I get UIBezierpath from UIImage like this..

enter image description here

I do not want full square path, Just want that path as shown in red border from UIImage..

I had gone through Link 1 and Link 2 but can't got success..

I had done following code to get 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 UIBezierpath that follows the shape of alphabets like A,B.. etc.

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

Thanks in advance..

Community
  • 1
  • 1
Mehul Mistri
  • 15,037
  • 14
  • 70
  • 94
  • Did you solve the issue? It seems there is still no answer to your question on stackoverflow... :o( – Dirk Aug 04 '14 at 20:23

2 Answers2

0

For other users looking for answers, an alternative approach can be found here (Using SVG as a source image file and PocketSVG to convert to paths)

Community
  • 1
  • 1
-5

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"];
jamil
  • 2,419
  • 3
  • 37
  • 64
  • Also check this tutorial ..i think its solve your problem.. http://blog.devedup.com/index.php/2010/03/03/iphone-animate-an-object-along-a-path/ – jamil May 22 '12 at 13:11
  • This answer isn't related to the question asked at all. They asked how to obtain a UIBezierPath that could draw that shape, not an animation about a path. – Brad Larson May 29 '12 at 14:33