首页 > 其他 > 详细

屏幕颜色闪烁

时间:2015-04-18 14:41:43      阅读:235      评论:0      收藏:0      [点我收藏+]

@implementation AppDelegate

- (void)dealloc

{

    [_window release];

    [super dealloc];

}

NSInteger a = 5;


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];

    self.window.backgroundColor = [UIColor whiteColor];

    [self.window makeKeyAndVisible];

    [_window release];

    view = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];

    view.backgroundColor = [UIColor yellowColor];

    [self.window addSubview:view];

    view.center = self.window.center;

    //(定时器)

    [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(change1) userInfo:nil repeats:YES];

    [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(changeColor) userInfo:nil repeats:YES];

    [view release];

    lable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 50)];

    lable.backgroundColor = [UIColor redColor];

   

    [view addSubview:lable];

    lable.center = view.center;

    lable.layer.borderColor = [UIColor blackColor].CGColor;

    lable.layer.borderWidth = 2;

    lable.layer.cornerRadius = 10;

    lable.layer.masksToBounds = YES;

    [lable release];

    return YES;

}

- (void)change1

{

    if (a > 0) {

        NSString *str = [NSString stringWithFormat:@"%ld", a];

        lable.text = str;

        lable.font = [UIFont boldSystemFontOfSize:40.0];

        lable.textAlignment = NSTextAlignmentCenter;

    }

    if (a == 0) {

        lable.text = @"闪瞎你";

        lable.font = [UIFont boldSystemFontOfSize:30.0];

        lable.textAlignment = NSTextAlignmentCenter;

        lable.textColor = [UIColor blueColor];

    }

    a--;

    }

- (void)changeColor

{if (a < 0){

    view.backgroundColor = [UIColor redColor];

    int a = arc4random()%(255 + 1);

    int b = arc4random()%(255 + 1);

    int c = arc4random()%(255 + 1);

    view.backgroundColor = [UIColor colorWithRed:a/255.0 green:b/255.0 blue:c/255.0 alpha:1];}

}


本文出自 “ios” 博客,请务必保留此出处http://10136044.blog.51cto.com/10126044/1634803

屏幕颜色闪烁

原文:http://10136044.blog.51cto.com/10126044/1634803

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!