有没有办法判断一个UIView是否正在进行动画?当我在View对象移动时打印它,我注意到有一个"animations"条目:
search bar should end editing: <UISearchBar: 0x2e6240; frame = (0 0; 320 88); text = ''; autoresize = W+BM; animations = { position=<CABasicAnimation: 0x6a69c40>; bounds=<CABasicAnimation: 0x6a6d4d0>; }; layer = <CALayer: 0x2e6e00>>
当动画停止并打印视图时,“animations”条目现在已经消失:
search bar should end editing: <UISearchBar: 0x2e6240; frame = (0 0; 320 88); text = ''; autoresize = W+BM; layer = <CALayer: 0x2e6e00>>
self?.view.layer.add(transition, forKey: "fade_animation")
- bmjohnslet alreadyAnimated = imageView.layer.animationKeys()?.isEmpty ?? true
- Nike Kov