我已经看了四周,但我一直未能找到这个简单的问题的答案。有没有办法让Swift CABasicAnimation动画的效果永久化? (意思是当动画结束后,视图不会重置到它在动画开始之前的状态。)迅速使动画效果永久
0
A
回答
1
有没有一种方法,使雨燕CABasicAnimation动画永久的效果
绝对如此。只需将您正在动画的属性设置为动画结束时的值即可。您可以在创建和添加动画的同时执行此操作。 (您可能会想打开隐动画关闭当你做到这一点,这样你就不会动画这个改变。)
例子从我自己的代码(我动画的transform
一个名为arrow
使其旋转层):
let startValue = arrow.transform
let endValue = CATransform3DRotate(
startValue, CGFloat(M_PI)/4.0, 0, 0, 1)
// change the layer, without implicit animation
// THIS IS WHAT YOU ARE ASKING ABOUT
CATransaction.setDisableActions(true)
arrow.transform = endValue
// construct the explicit animation
let anim = CABasicAnimation(keyPath:"transform")
anim.duration = 0.8
anim.fromValue = NSValue(CATransform3D:startValue)
anim.toValue = NSValue(CATransform3D:endValue)
// ask for the explicit animation
arrow.addAnimation(anim, forKey:nil)
+0
有关此代码背后原理的完整讨论,请参阅我的书:http://www.apeth.com/iOS书/ ch17.html#_using_a_cabasicanimation – matt
相关问题
- 1. Android永久动画
- 2. UIView.animateWithDuration迅速循环动画
- 3. 迅速UIView.animate跳过动画
- 4. addSubview破坏动画迅速
- 5. 滑出动画在迅速
- 6. 画动画圈中迅速3
- 7. 迅速使缓存无效
- 8. 如果迅速
- 9. 关于速度的动画效果
- 10. 未能动画在迅速3
- 11. 添加动画序列中迅速
- 12. 迅速停止360度的动画
- 13. 动画效果
- 14. Jquery使用动画效果动画效果的Flash动画文本
- 15. 迅速IOS数据持久性的UIImage
- 16. 使用迅速
- 17. 迅速动态UIAlertController
- 18. jQuery的动画动画效果后生效,之后动画效果
- 19. 301永久移动
- 20. 永久SensorEventListener震动
- 21. 苹果迅速 - 从可变
- 22. 动画效果ngRepeat
- 23. iOS动画效果
- 24. Android动画效果
- 25. Android。动画效果
- 26. uiimage动画效果
- 27. 动画jQuery效果
- 28. 为angular2动画效果应用动画效果
- 29. Android滑动效果动画
- 30. CSS动画(颤动效果)
你应该fillModes https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CAMediaTiming_protocol/index.html#/看看/ apple_ref/doc/constant_group/Fill_Modes –