场景:存在一个UILabel实例,对它做缩放,如何清除知道他正在缩放?
个人感觉 用label的bool属性记录最好
没有找到能判断是否正在执行动画的相关的API,只有下面的方法,通过判断isAnimating 来判断
// 设置初始值(最好使用全局或者属性)
__block BOOL isAnimating =YES;
self.transform = CGAffineTransformMakeScale(6, 6);
[UIView animateKeyframesWithDuration:0.333 delay:0 options:0 animations:^{
self.transform = CGAffineTransformMakeScale(1, 1);
} completion:^(BOOL finished) {
// 成功回调改为NO
isAnimating = NO;
completion();
}];
-(BOOL)isAnimated
{
BOOL animated = self.layer.animationKeys.count > 0;
for (UIView *subView in self.subviews) {
animated |= subView.isAnimated;
}
return animated;
}