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