【发布时间】:2016-08-24 08:53:14
【问题描述】:
我用 BezierPath 遮罩了一张图片。 我想为那个蒙版图像制作动画。
我的代码如下:
UIBezierPath* bezierPath = [UIBezierPath bezierPath];
[bezierPath moveToPoint: CGPointMake(84.95, 205.11)];
[bezierPath addCurveToPoint: CGPointMake(122.89, 232.14) controlPoint1: CGPointMake(84.95, 205.11) controlPoint2: CGPointMake(110.81, 223.56)];
[bezierPath addCurveToPoint: CGPointMake(124.33, 233.04) controlPoint1: CGPointMake(123.37, 232.46) controlPoint2: CGPointMake(123.85, 232.78)];
[bezierPath closePath];
CAShapeLayer *maskImage = [CAShapeLayer layer];
maskImage.path = bezierPath.CGPath;
maskImage.fillColor = [[UIColor blackColor] CGColor];
_myImageView.layer.mask = maskImage;
CAShapeLayer *border = [CAShapeLayer layer];
border.path = bezierPath.CGPath;
border.strokeColor = [UIColor redColor].CGColor;
border.fillColor = [[UIColor clearColor] CGColor];
border.lineWidth = 5;
[_myImageView.layer addSublayer:border];
如何制作动画?
谢谢
【问题讨论】:
-
请出示您的 bezierPath 编码
-
@user3182143,我添加了 bezierPath 的代码。
-
@user2526811 你想为这个贝塞尔路径绘制动画吗??
-
@SiddharthSunil,是的或 _myImageView.layer.mask = maskImage ...
-
请检查我的答案兄弟。
标签: ios objective-c iphone animation uibezierpath