第13月第13天 iOS 放大消失动画

本文介绍了一个简单的倒计时视图动画实现方法。通过UIView的animateWithDuration方法,可以改变UILabel的transform和alpha属性来完成缩放和淡出效果。当倒计时结束时,会触发一个代理方法,并从父视图移除自身。

1.

- (void) animate
{
    [UIView animateWithDuration:0.9 animations:^{
    
        CGAffineTransform transform = CGAffineTransformMakeScale(2.5, 2.5);
        self.countdownLabel.transform = transform;
        self.countdownLabel.alpha = 0;
        
    } completion:^(BOOL finished) {
        if (finished) {
            
             if (self.currentCountdownValue == 0) {
                 [self stop];
                 if (self.delegate) {
                     [self.delegate countdownFinished:self];
                     [self removeFromSuperview];
                 }
                 
             } else {

                self.countdownLabel.transform = CGAffineTransformIdentity;
                self.countdownLabel.alpha = 1.0;
                
                self.currentCountdownValue--;
                if (self.currentCountdownValue == 0) {
                    self.countdownLabel.text = self.finishText;
                } else {
                    self.countdownLabel.text = [NSString stringWithFormat:@"%d", self.currentCountdownValue ];
                }
            }
        }
    }];
}

 

https://github.com/simpliflow/SFCountdownView

 

转载于:https://www.cnblogs.com/javastart/p/7660054.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值