UI中霓虹灯效果代码

来源:互联网 发布:优酷网软件下载 编辑:程序博客网 时间:2024/03/28 23:00
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];    // Override point for customization after application launch.        NSMutableArray *arr = [NSMutableArray arrayWithObjects:[UIColor redColor], [UIColor yellowColor],[UIColor blueColor],[UIColor greenColor],[UIColor grayColor],[UIColor purpleColor],[UIColor orangeColor],nil];    for (int i = 0 ; i < 7; i++) {        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0 + i * 20, 0 + i *20, 320 - 40 * i , 568 - i * 40)];        view.tag = 100 + i;        view.backgroundColor = arr[i];        [self.window addSubview:view];        [view release];    }    [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(time) userInfo:nil  repeats:YES];            self.window.backgroundColor = [UIColor whiteColor];    [self.window makeKeyAndVisible];    return YES;}- (void)time{    UIColor *temp = [self.window viewWithTag:100 ].backgroundColor;    for (int i = 0; i <7; i++) {        [self.window viewWithTag:100 +i ].backgroundColor =  [self.window viewWithTag:101 +i ].backgroundColor;    }    [self.window viewWithTag:106 ].backgroundColor = temp;}

1 0