UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(320/2 - 200/2, 100, 200, 100)];
view1.backgroundColor = [UIColor blackColor];
view1.tag = 1;
[self.window addSubview:view1];
[view1 release];
UIView *view2 = [[UIView alloc]initWithFrame:CGRectMake(320/2 - 150/2, 110, 150, 80)];
view2.backgroundColor = [UIColor redColor];
view2.tag = 2;
[self.window addSubview:view2];
[view2 release];
UIView *view3 = [[UIView alloc]initWithFrame:CGRectMake(320/2 - 100/2, 120, 100, 60)];
view3.backgroundColor = [UIColor yellowColor];
view3.tag = 3;
[self.window addSubview:view3];
[view3 release];
timer = [NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(timerFireMethod:)
userInfo:nil
repeats:YES];
-(void)timerFireMethod:(NSTimer *)theTime{
if(seconds == 0){//seconds已被初始化为10
[theTime invalidate];
[self.window removeFromSuperview];
}else{
seconds --;
UIView *myView = [self.window viewWithTag:seconds % 3+1];
[self.window bringSubviewToFront:myView];//将myView移到最前
myView.transform = CGAffineTransformRotate(myView.transform, 0.5);//myView旋转动画
}
}