从UIImage掩蔽中获取UIBezierpath

6

如何从 UIImage 中获取这样的 UIBezierpath..

enter image description here

我不想要完整的正方形路径,只想要来自 UIImage 的红色边框路径..

我已经查看了 链接1链接2,但没有成功..

我尝试了以下代码以获取遮罩路径..

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

基本上,我想获得跟随字母形状(如A、B等)的UIBezierpath。请告诉我是否可能获得这种类型的路径?谢谢。

你解决了这个问题吗?在stackoverflow上似乎还没有人回答你的问题... :o( - Dirk
2个回答

0

对于其他寻找答案的用户,可以在这里找到另一种方法(使用SVG作为源图像文件并使用PocketSVG将其转换为路径)


-5

试着用这段代码:

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"];

还有这个教程,我认为它可以解决你的问题:http://blog.devedup.com/index.php/2010/03/03/iphone-animate-an-object-along-a-path/ - jamil
这个回答与问题毫无关系。他们问的是如何获得一个可以绘制该形状的UIBezierPath,而不是有关路径的动画。 - Brad Larson

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接