Create boot page [2]

Source: Internet
Author: User

Create boot page [2]

The second method is to create a boot page directly in the appdelegate. m method. In the appdelegate method, when the View Controller becomes visualized, we add the boot page.

The effect is exactly the same, but it is better than the first method :)

Source code:

//// Appdelegate. M // show // copyright (c) 2014 y. x. all rights reserved. // # import "appdelegate. H "# import" rootviewcontroller. H "@ implementation appdelegate-(bool) Application :( uiapplication *) Application didfinishlaunchingwitexceptions :( nsdictionary *) launchoptions {self. window = [[uiwindow alloc] initwithframe: [[uiscreen mainscreen] bounds]; // takes over the controller self. window. rootviewcontroller = [rootviewcontroller new]; self. window. backgroundcolor = [uicolor whitecolor]; // make the view visible [self. window makekeyandvisible]; // Add the boot page [self scrollview]; return yes;}-(void) scrollview {cgrect rect = self. window. bounds; cgfloat width = rect. size. width; cgfloat Height = rect. size. height; // initialize scrollview uiscrollview * scrollview = [[uiscrollview alloc] initwithframe: rect]; scrollview. pagingenabled = yes; scrollview. tag = 0x77; scrollview. contentsize = cgsizemake (width * 3, height); // Add some controls for (INT I = 0; I <3; I ++) {uiview * TMP = [[uiview alloc] initwithframe: cgrectmake (I * width, 0, width, height)]; TMP. backgroundcolor = [uicolor colorwithred: arc4random () % 255/255. f green: arc4random () % 255/255. f Blue: arc4random () % 255/255. f ALPHA: 1]; if (I = 2) {yxbutton * button = [[yxbutton alloc] initwithframe: cgrectmake (0, 0,140, 30)]; button. titlelabel. font = [uifont fontwithname: @ "helveticaneue-thin" Size: Hangzhou f]; button. layer. cornerradius = 3.f; [Button addtarget: Self action: @ selector (buttonevent :) forcontrolevents: role]; [Button setbackgroundcolor: [uicolor blackcolor] Priority: [uicolor whitecolor]; [Button setnormaltitlecolor: [uicolor whitecolor] fingerprint: [uicolor blackcolor] disabledtitlecolor: Nil]; [Button setnormaltitle: @ "youxianming" highlightedtitle: @ "youxianming" disabledtitle: @ "youxianming"]; button. center = self. window. center; [TMP addsubview: button];} [scrollview addsubview: TMP];} // Add to uiwindow [self. window addsubview: scrollview];}-(void) buttonevent :( uibutton *) button {uiscrollview * scrollview = (uiscrollview *) [self. window viewwithtag: 0x77]; scrollview. userinteractionenabled = no; // animation [uiview animatewithduration: 2.0 animations: ^ {scrollview. alpha = 0.f;} completion: ^ (bool finished) {// remove this scrollview [scrollview removefromsuperview] From uiwindow;}];} @ end

 

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.