[英]UIView circle mask animation
I have an abstract strange shaped UIView. 我有一个抽象的奇怪形状的UIView。 And I need to display a smooth appearance animation.
而且我需要显示平滑的外观动画。
I assume I should apply that animation to the mask above that view. 我认为我应该将该动画应用于该视图上方的蒙版。 The mask is going to be circle shaped.
面罩将变成圆形。 So user will see the 1'2'3'4' sequence.
因此用户将看到1'2'3'4'序列。 How can I implement that?
我该如何实施? I suppose I should apply some affine transformation to the mask view.
我想我应该对蒙版视图应用仿射变换。 In that case, what should be the original shape of the mask?
在这种情况下,面罩的原始形状应该是什么? A vertical line?
一条垂直线?
A simple example,suppose I have a 100*100 imageview
, 一个简单的例子,假设我有一个100 * 100的
imageview
,
Note:to make it simple,I use hard code numbers 注意:为简单起见,我使用硬代码编号
CAShapeLayer * maskLayer = [CAShapeLayer layer];
maskLayer.bounds = CGRectMake(0, 0, 100, 100);
maskLayer.position = CGPointMake(50, 50);
UIBezierPath * path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(50.0, 50.0) radius:50 startAngle:0 endAngle:M_PI *2 clockwise:true];
maskLayer.path = path.CGPath;
maskLayer.fillColor = [UIColor clearColor].CGColor;
maskLayer.strokeColor = [UIColor blackColor].CGColor;
maskLayer.strokeEnd = 0.0;
maskLayer.lineWidth = 100;
self.imageview.layer.mask = maskLayer;
CABasicAnimation * animation = [CABasicAnimation animation];
animation.keyPath = @"strokeEnd";
animation.toValue = @(1.0);
animation.duration = 2.0;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;
[maskLayer addAnimation:animation forKey:@"keyFrame"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.