Three-color space-time Gate type marquee 1

Source: Internet
Author: User

#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 get the screen size of the hardware device

CGRectMake (0, 0, 320, 568) Setting the screen size is not variable

Self.window=[[uiwindow Alloc]initwithframe:[uiscreen Mainscreen].bounds];

Self.window=[[uiwindow alloc]initwithframe:cgrectmake (0, 0, 320, 568-20)];//run only once

Self.window.backgroundcolor=[uicolor redcolor];//Setting the background color

[Nstimer scheduledtimerwithtimeinterval:1 target:self selector: @selector (timeraction:) Userinfo:nil Repeats:yes];

Marquee idea-"Set timer characteristics, run once per second"-"Set global variables TimeValue settings-" Two by odd even, more than one set a local variable to find the remainder. Can. or direct introduction of digital redundancy is also possible. The above and below comments are all error-based and are for training.

[Self.window makekeyandvisible]; //Let the currently generated window appear at the front end

window design, color set, before the front of the window to add things

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

Three-color space-time Gate type marquee 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.