iOS倒计时的动画效果

来源:互联网 发布:淘宝下拉框关键词软件 编辑:程序博客网 时间:2024/05/22 10:44

-(void)countDown:(int)count{

    

   if(count <=0){

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

       return;

    }

    

    

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

    lblCountDown.textColor = [UIColorredColor];

    lblCountDown.font = [UIFontboldSystemFontOfSize:66];

    lblCountDown.backgroundColor = [UIColorclearColor];

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

    [self.viewaddSubview:lblCountDown];

    

    [UIViewanimateWithDuration:1

                         delay:0

                        options:UIViewAnimationCurveEaseOut

                    animations:^{

                         lblCountDown.alpha =0;

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

                     }

                    completion:^(BOOL finished) {

                         [lblCountDownremoveFromSuperview];

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

                         [selfcountDown:count -1];

                         }

                     ];

}

1 0