iOS 霓虹灯效果(同种颜色依次向外扩展)

来源:互联网 发布:优酷网软件下载 编辑:程序博客网 时间:2024/04/24 20:20
#import "ZXHAppDelegate.h"<span style="font-size:18px;">@implementation ZXHAppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];    // Override point for customization after application launch.            /*    NSArray *arr = [NSArray arrayWithObjects:[UIColor redColor],[UIColor orangeColor],[UIColor yellowColor],[UIColor greenColor],[UIColor cyanColor],[UIColor blueColor],[UIColor purpleColor], nil];    for (NSInteger i = 0; i < 7; i ++) {        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0 + i * 20, 0 + i *20, 320 - 40 * i , 568 - i * 40)];        view.backgroundColor = arr[random()%6];                [self.window addSubview:view];        [view release];}     */    //红色视图    UIView *redView=[[UIView alloc] initWithFrame:CGRectMake(0, 153, 320, 320)];    redView.backgroundColor=[UIColor redColor];    redView.tag = 101;    [self.window addSubview:redView];    [redView release];            //橙色视图    UIView *oriangeView=[[UIView alloc] initWithFrame:CGRectMake(20, 20, 280, 280)];    oriangeView.backgroundColor=[UIColor orangeColor];    oriangeView.tag = 102;    [redView addSubview:oriangeView];    [oriangeView release];        //黄色视图    UIView *yellowView=[[UIView alloc] initWithFrame:CGRectMake(20, 20, 240, 240)];    yellowView.backgroundColor=[UIColor yellowColor];    yellowView.tag = 103;    [oriangeView addSubview:yellowView];    [yellowView release];            //绿色视图    UIView *greenView=[[UIView alloc] initWithFrame:CGRectMake(20,20, 200, 200)];    greenView.backgroundColor=[UIColor greenColor];    greenView.tag = 104;    [yellowView addSubview:greenView];    [greenView release];        //青色视图    UIView *cyanView=[[UIView alloc] initWithFrame:CGRectMake(20, 20, 160, 160)];    cyanView.backgroundColor=[UIColor cyanColor];    cyanView.tag = 105;    [greenView addSubview:cyanView];    [cyanView release];        //蓝色视图    UIView *blueView=[[UIView alloc] initWithFrame:CGRectMake(20, 20, 120, 120)];    blueView.backgroundColor=[UIColor blueColor];    blueView.tag = 106;    [cyanView addSubview:blueView];    [blueView release];        //紫色视图        UIView *purpleView=[[UIView alloc] initWithFrame:CGRectMake(20, 20, 80, 80)];    purpleView.backgroundColor=[UIColor purpleColor];    purpleView.tag = 107;    [blueView addSubview:purpleView];    [purpleView release];    [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(Ltime) userInfo:nil repeats:YES];            self.window.backgroundColor = [UIColor whiteColor];    [self.window makeKeyAndVisible];    return YES;}- (void)Ltime{    UIColor *temp = [self.window viewWithTag:101].backgroundColor;    for (int i = 0; i < 6; i++) {        [self.window viewWithTag:101 + i].backgroundColor = [self.window viewWithTag:102 + i].backgroundColor;    }    [self.window viewWithTag:107].backgroundColor = temp;}</span>

0 0
原创粉丝点击