标签:
//每隔一秒改变一次颜色
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(changeColor) userInfo:nil repeats:YES];
#pragma mark 改变颜色
- (void)changeColor{
//动画开始
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
self.view.backgroundColor = [[UIColor alloc]initWithRed:(double)(arc4random()%256)/256 green:(double)(arc4random()%256)/256 blue:(double)(arc4random()%256)/256 alpha:0.5];
//动画结束
[UIView commitAnimations];
}
标签:
原文地址:http://blog.csdn.net/ytuzhangziyao/article/details/42171401