iOS倒计时的动画效果

-(void)countDown:(int)count{

    

    if(count <=0){

        //倒计时已到,作需要作的事吧。

        return;

    }

    

    

    UILabel* lblCountDown = [[UILabel alloc] initWithFrame:CGRectMake(260, 120, 50, 50)];

    lblCountDown.textColor = [UIColor redColor];

    lblCountDown.font = [UIFont boldSystemFontOfSize:66];

    lblCountDown.backgroundColor = [UIColor clearColor];

    lblCountDown.text = String(@"%d",_SettedCountDown);

    [self.view addSubview:lblCountDown];

    

    [UIView animateWithDuration:1

                          delay:0

                        options:UIViewAnimationCurveEaseOut

                     animations:^{

                         lblCountDown.alpha = 0;

                         lblCountDown.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.5, 0.5);

                     }

                     completion:^(BOOL finished) {

                         [lblCountDown removeFromSuperview];

 //递归调用,直到计时为零

                         [self countDown:count -1];

                         }

                     ];

}

猜你喜欢

转载自blog.csdn.net/gaoyp/article/details/20522289