您的位置:首页 > 产品设计 > UI/UE

UILable缩小字体同比例缩小_附加倒计时

2013-10-29 14:47 537 查看
#import "ViewController.h"

@interface ViewController (){
NSInteger count;        //计数器
UILabel *lable;         //文本试图
NSArray *textArray;     //文字数组
NSTimer *timer;         //定时器
}

@end

@implementation ViewController
- (void)dealloc{
[lable release];
[textArray release];
[super dealloc];
}
- (void)viewDidLoad {

[super viewDidLoad];

textArray = [[NSArray alloc] initWithObjects:@"3",@"2",@"1",@"G O", nil];

lable = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 160, 80)];
lable.textAlignment = NSTextAlignmentCenter;
lable.backgroundColor = [UIColor orangeColor];
lable.font = [UIFont boldSystemFontOfSize:40];
lable.center = self.view.center;
lable.text = [textArray objectAtIndex:0];
[self.view addSubview:lable];

CABasicAnimation *animationZoomOut=[CABasicAnimation animationWithKeyPath:@"transform.scale"];
animationZoomOut.duration=4;
animationZoomOut.autoreverses=NO;
animationZoomOut.repeatCount=1;
animationZoomOut.toValue=[NSNumber numberWithFloat:0];
animationZoomOut.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];

[lable.layer addAnimation:animationZoomOut forKey:nil];

timer = [NSTimer scheduledTimerWithTimeInterval:0.8 target:self selector:@selector(textCheck) userInfo:nil repeats:YES];

}
- (void)textCheck{
if (count < textArray.count-1) {
count ++;
}else{
[timer invalidate];
timer = nil;
}
lable.text = [textArray objectAtIndex:count];
[self.view reloadInputViews];
}
@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: