iOS倒計時的動畫效果 – iPhone手機開發技術文章 iPhone軟體開發教學課程

-(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];

}

];

}

發佈留言