iOS 开发记录

iOS layer 动画自动停止

2017-05-27  本文已影响0人  拇指猿

问题描述:切换 tabBarController 或者 push 一个controller时,离开 layer 动画所在的 controller 并且动画是执行状态时,回到layer 所在的 controller layer 动画会自动停止。

CABasicAnimation *strokeEndAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];

strokeEndAnimation.fromValue = @(0.25);

strokeEndAnimation.toValue = @(1);

strokeEndAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];

strokeEndAnimation.duration = 10;

strokeEndAnimation.repeatCount = MAXFLOAT;

strokeEndAnimation.fillMode = kCAFillModeRemoved;

[_shapeLayer addAnimation:strokeEndAnimation forKey:@"strokeEndAnimation"];

解决办法是设置动画的这个属性
strokeEndAnimation.removedOnCompletion = NO;

上一篇下一篇

猜你喜欢

热点阅读