//
// AppDelegate.m
// 作业_彩色变换
//
// Created by dllo on 15/7/29.
// Copyright (c) 2015年 zhozhicheng. All rights reserved.
//
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
-(void)dealloc
{
[_window release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
[_window release];
UIView *view1=[[UIView alloc] initWithFrame:CGRectMake(20, 20, 300, 300)];
view1.backgroundColor=[UIColor blackColor];
[self.window addSubview:view1];
[view1 release];
UIView *view2=[[UIView alloc] initWithFrame:CGRectMake(40, 40, 260, 260)];
view2.backgroundColor=[UIColor yellowColor];
[self.window addSubview:view2];
[view2 release];
UIView *view3=[[UIView alloc] initWithFrame:CGRectMake(60, 60, 220, 220)];
view3.backgroundColor=[UIColor blueColor];
[self.window addSubview:view3];
[view3 release];
UIView *view4=[[UIView alloc] initWithFrame:CGRectMake(80, 80, 180, 180)];
view4.backgroundColor=[UIColor redColor];
[self.window addSubview:view4];
[view4 release];
UIView *view5=[[UIView alloc] initWithFrame:CGRectMake(100, 100, 140, 140)];
view5.backgroundColor=[UIColor orangeColor];
[self.window addSubview:view5];
[view5 release];
UIView *view6=[[UIView alloc] initWithFrame:CGRectMake(120, 120, 100, 100)];
view6.backgroundColor=[UIColor cyanColor];
[self.window addSubview:view6];
[view6 release];
UIView *view7=[[UIView alloc] initWithFrame:CGRectMake(140, 140, 60, 60)];
view7.backgroundColor=[UIColor greenColor];
[self.window addSubview:view7];
[view7 release];
view1.tag=1;
view2.tag=2;
view3.tag=3;
view4.tag=4;
view5.tag=5;
view6.tag=6;
view7.tag=7;
NSTimer *timer=[NSTimer scheduledTimerWithTimeInterval:0.5
target:self selector:@selector(changeColor) userInfo:nil repeats:YES];
return YES;
}
-(void)changeColor
{
UIColor *color =[self.window viewWithTag:7].backgroundColor;
for (int i=6; i>0; i--) {
[self.window viewWithTag:i+1].backgroundColor=[self.window viewWithTag:i].backgroundColor;
}
[self.window viewWithTag:1].backgroundColor=color;
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end