美文网首页
常用礼物数字combo动画

常用礼物数字combo动画

作者: 活最好的自己 | 来源:发表于2019-02-26 11:41 被阅读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;
            }];
        }];
    }
    

    相关文章

      网友评论

          本文标题:常用礼物数字combo动画

          本文链接:https://www.haomeiwen.com/subject/stqayqtx.html