0
更新:動畫一個CAShapeLayer同時通過中心物業移動及其母公司的UIView
這裏是沒有問題的。原來我每次移動點都重新添加動畫。代碼中的其他地方,我只是完全掩飾它。請忽略這個問題。
末更新
我有一個UIView它只是充當一個UIImageView和CAShaperLayer的容器。形狀圖層正在繪製一個圓形,並且我已經爲該形狀圖層添加了一個路徑動畫以使其成爲脈衝。我希望能夠使用UIView的中心屬性同時脈動圓並移動容器視圖。但是,當我在容器UIView上設置center屬性時,脈衝動畫從其開始處重新開始,無論它在動畫中的位置如何。
如何防止脈衝動畫重新啓動?
脈衝動畫:
CGRect startRect = CGRectMake(-10 + (self.bounds.size.width/2),
-10 + (self.bounds.size.height/2),
20,
20);
CGMutablePathRef fromPath = CGPathCreateMutable();
CGPathAddEllipseInRect(fromPath, NULL, startRect);
CGRect endRect = CGRectMake(-20 + (self.bounds.size.width/2),
-20 + (self.bounds.size.height/2),
40,
40);
CGMutablePathRef toPath = CGPathCreateMutable();
CGPathAddEllipseInRect(toPath, NULL, endRect);
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"];
animation.fromValue = (id)fromPath;
animation.toValue = (id)toPath;
CGPathRelease(fromPath);
CGPathRelease(toPath);
animation.duration = 2.0f;
animation.repeatCount = HUGE_VALF;
[self.myCircleLayer addAnimation:animation forKey:self.pathAnimationKey];
我做移動容器視圖:
self.myContainerView.center = newPoint;