- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor grayColor];
self.view.alpha = 0;
[self createProgressView];
[self createTimer];
}
- (void)createProgressView{
//progress的值是0-1的
UIProgressView * progress = [[UIProgressView alloc] initWithFrame:CGRectMake(30, 100, 260, 400)];
progress.tag = 111;
[self.view addSubview:progress];
}
- (void)createTimer{
//设置一个定时器 每0.1s执行一下changed:函数
NSTimer * timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(changed:) userInfo:nil repeats:YES];
}
- (void)changed:(NSTimer *)timer{
//[self.view viewWithTag:111] 根据tag值获取此界面上得view
UIProgressView * progress = (UIProgressView *)[self.view viewWithTag:111];
//改变progress的值 调用progress.progress 让背景透明度改变
if (progress.progress >= 0) {
progress.progress += 0.01;
self.view.alpha = progress.progress;
}
}