常用礼物数字combo动画
2019-02-26 本文已影响9人
活最好的自己
/**
添加礼物数字的动画
*/
- (void)addComboAnimation{
if (CGAffineTransformIsIdentity(self.numberImgView.transform) ) {
// 没有正在播放的动画
dispatch_async(dispatch_get_main_queue(), ^{
[self _animateGiftNumImg];
});
} else {
// 有正在播放的动画, 就延迟
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self _animateGiftNumImg];
});
}
}
/**
礼物数字图片先放大然后回归正常
*/
- (void)_animateGiftNumImg {
UIView *comboView = self.numberImgView.rootView;
comboView.transform = CGAffineTransformIdentity;
[UIView animateWithDuration:0.1 animations:^{
// 放大
comboView.transform = CGAffineTransformMakeScale(5, 5);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.1 animations:^{
// 复原
comboView.transform = CGAffineTransformIdentity;
}];
}];
}