6

我怎么能得到UIBezierpath这样的UIImage..

在此处输入图像描述

我不想要完整的方形路径,只想要 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)]; 

基本上我想得到UIBezierpath它遵循字母的形状,如 A,B .. 等。

请告诉我这是否可能获得这种类型的路径?

提前致谢..

4

2 回答 2

0

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

于 2015-03-09T22:19:25.027 回答
-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"];
于 2012-05-22T11:53:49.370 回答