读书人

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

发布时间: 2013-10-31 12:03:52 作者: rapoo

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

#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

读书人网 >移动开发

热点推荐