三色时空门式跑马灯1

 

 

 

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

{

@public

    NSInteger timeValue;

}

@property (strong, nonatomic) UIWindow *window;

 @end

 

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

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

   

    //[UIScreen  mainScreen].bounds获取硬件设备的屏幕尺寸

    //CGRectMake(0, 0, 320, 568)将屏幕大小设置不可变

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

    //self.window=[[UIWindow   alloc]initWithFrame:CGRectMake(0, 0, 320, 568-20)];//开机只运行一次

    

       self.window.backgroundColor=[UIColor redColor];//设置背景颜色

    

 

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

// 跑马灯思路-》设置定时器《定时器特性,每秒运行一次》-》设置全局变量timeValue设置-》两个按奇偶数,多个则再设置一个局部变量求余。即可。或直接引入数字求余也可以。此处上面和下面注释的全为错误的,以此为训。

    [self.window makeKeyAndVisible];//让当前产生的窗口展示在最前端

 //窗口设计好了,颜色设置好了,在窗口最前端之前添加东西

   return YES;

}

-(void)timerAction:(NSTimer *)timer{

    

    UIView *aView=[[UIView alloc]initWithFrame:CGRectMake(45, 45, 230, 468)];

    UIView *aView1=[[UIView alloc]initWithFrame:CGRectMake(90, 90, 140, 368)];

    UIView *aView2=[[UIView alloc]initWithFrame:CGRectMake(135, 135, 50, 268)];

    timeValue++;

    int i=3;

    if (timeValue%i==0) {

        aView.backgroundColor=[UIColor yellowColor];

        aView1.backgroundColor=[UIColor blueColor];

        aView2.backgroundColor=[UIColor greenColor];

        [self.window addSubview:aView];

        [self.window addSubview:aView1];

        [self.window addSubview:aView2];

           }

    if (timeValue%i==1) {

        aView.backgroundColor=[UIColor blueColor];

        aView1.backgroundColor=[UIColor greenColor];

        aView2.backgroundColor=[UIColor yellowColor];

        [self.window addSubview:aView];

        [self.window addSubview:aView1];

        [self.window addSubview:aView2];

 

    }

    if (timeValue%i==2) {

        aView.backgroundColor=[UIColor greenColor];

        aView1.backgroundColor=[UIColor yellowColor];

        aView2.backgroundColor=[UIColor blueColor];

        [self.window addSubview:aView];

        [self.window addSubview:aView1];

        [self.window addSubview:aView2];

    }

}

 @end

 

posted @ 2015-08-02 13:34  OIMMZC  阅读(272)  评论(0编辑  收藏  举报