IOS UI programming-Implementation of neon lights, iosui-neon lights

Source: Internet
Author: User

IOS UI programming-Implementation of neon lights, iosui-neon lights

I have been studying UI programming for three or four days. I have learned some basic views and controls over the past few days, such as UIView, UIlabel, and UIButton ., to learn about UI programming, you can see the effect by writing your own code. This is very different from C and OC. So I tried a simple view color transformation application, that is, the neon lights. The implemented functions can be from inside to outside, from outside to inside, or paused. Due to the limited level, and the lack of NSTimer learning, I learned a simple application from the Internet, so there may be some problems in code implementation, and the algorithm is not optimal, I also hope that the experts will criticize and give advice. Paste the following picture:


The following is a code implementation:

# Import "ZZAppDelegate. h "@ interface ZZAppDelegate () {UIView * _ containerView; NSTimer * _ timer;} @ end @ implementation ZZAppDelegate-(BOOL) application :( UIApplication *) application metadata :( NSDictionary *) launchOptions {self. window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]; // Override point for customization after application launch. self. window. backgroundColor = [UIColor grayColor]; _ containerView = [[UIView alloc] initWithFrame: CGRectMake (0, 0,320,568)]; _ containerView. backgroundColor = [UIColor clearColor]; [self. window addSubview: _ containerView]; [_ containerView release]; // view layout NSArray * array = [NSArray arrayWithObjects: [UIColor redColor], [UIColor orangeColor], [UIColor yellowColor], [UIColor greenColor], [UIColor blueColor], [UIColor cyanColor], [UIColor purpleColor], nil]; for (int I = 0; I <7; I ++) {UIView * view = [[UIView alloc] initWithFrame: CGRectMake (20 + I * 20,120 + I * 20,280-I * 40,280-I * 40)]; view. backgroundColor = array [I]; view. tag = I + 200; NSLog (@ "% ld", (long) view. tag); [_ containerView addSubview: view]; [view release];} // create the UIButton * button1 = [UIButton buttonWithType: UIButtonTypeSystem]; button1.frame = CGRectMake (40,450, 70, 40); button1.backgroundColor = [UIColor cyanColor]; [button1 setTitle: @ "from inside out" forState: UIControlStateNormal]; [button1 addTarget: self action: @ selector (changeFromInToOut) forControlEvents: UIControlEventTouchUpInside]; button1.layer. cornerRadius = 7; [_ containerView addSubview: button1]; // create stop button UIButton * button2 = [UIButton buttonWithType: Disabled]; button2.frame = CGRectMake (125,450, 70, 40 ); button2.backgroundColor = [UIColor cyanColor]; [button2 setTitle: @ "stop" forState: UIControlStateNormal]; [button2 addTarget: self action: @ selector (stop) forControlEvents: callback]; button2.layer. cornerRadius = 7; [_ containerView addSubview: button2]; // create an out-of-box button UIButton * button3 = [UIButton buttonWithType: bytes]; button3.frame = CGRectMake (210,450, 70, 40); button3.backgroundColor = [UIColor cyanColor]; [button3 setTitle: @ "outside" forState: UIControlStateNormal]; [button3 addTarget: self action: @ selector (listener) forControlEvents: UIControlEventTouchUpInside]; button3.layer. cornerRadius = 7; [_ containerView addSubview: button3]; [self. window makeKeyAndVisible]; return YES;} // event triggered by the internal and external buttons-(void) changeFromInToOut {_ timer = [nst1_scheduledtimerwithtimeinterval: 0.3 target: self selector: @ selector (changetimed out) userInfo: nil repeats: YES];} // event triggered by an out-of-the-box button-(void) changeFromOutToIn {_ timer = [nst1_scheduledtimerwithtimeinterval: 0.3 target: self selector: @ selector (changeOutToIn) userInfo: nil repeats: YES];} // pause the timer-(void) stop {[_ timer invalidate];} // color switching from the inside out loop-(void) changequota out {UIView * temp = [[UIView alloc] init]; int I = 200; temp. backgroundColor = [_ containerView viewWithTag: 200]. backgroundColor; for (I = 200; I <207; I ++) {[_ containerView viewWithTag: I]. backgroundColor = [_ containerView viewWithTag: I + 1]. backgroundColor;} [_ containerView viewWithTag: 206]. backgroundColor = temp. backgroundColor; [temp release];} // color exchanged by external and inner loops-(void) changeOutToIn {UIView * temp = [[UIView alloc] init]; int I = 206; temp. backgroundColor = [_ containerView viewWithTag: 206]. backgroundColor; for (I = 206; I> = 0; I --) {[_ containerView viewWithTag: I]. backgroundColor = [_ containerView viewWithTag: I-1]. backgroundColor;} [_ containerView viewWithTag: 200]. backgroundColor = temp. backgroundColor; [temp release];}-(void) dealloc {[_ window release]; [super dealloc];} @ end



Ios UI design: iphone has two resolutions: 320*480 and 640*960, so I only need to do either of them when designing an APP.

Let's do both of them. It is said that we will automatically call what principle. I don't know. Now we have five more resolutions.
 
In iOS, how does one program to call mobile safari to play a video?

You can use UIWebView or directly call the safari browser. [[UIApplication sharedApplication] openURL: someHTTP_or_HTTPS_URL]
 

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.