Unified set navigation bar and status bar code

Source: Internet
Author: User

Unified set navigation bar and status bar code:

#import "AppDelegate.h"#import "SZMMainTabBarController.h"@interfaceappdelegate ()@end@implementationappdelegate-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {//Create WindowSelf.window =[[UIWindow Alloc]initwithframe:[uiscreen mainscreen].bounds]; //Create to ControllerSzmmaintabbarcontroller *MAINVC =[[Szmmaintabbarcontroller alloc]init]; //set MAINVC as the root Controller for windowSelf.window.rootViewController =MAINVC; //Unified Settings Navigation bar[self setnavbar]; //Unified Setup Status bar[self setstatusbar:application]; //set Self.window as the primary controller and display[Self.window makekeyandvisible]; returnYES;}//Unified Settings Navigation bar- (void) setnavbar{//use the Appearance method to get the global proxy object, then set the global proxy object to set all the navigation bars    Uinavigationbar *navbar = [Uinavigationbar appearance]; [NavBar setbackgroundimage:[uiimage imagenamed:@ "NavBar64"] Forbarmetrics:    Uibarmetricsdefault];    Nsdictionary *arrtu = @{nsforegroundcolorattributename:[uicolor Whitecolor]}; //Modify the color of title text in the navigation bar[NavBar Settitletextattributes:arrtu]; //Modify the color of the return button in the navigation bar [NavBar settintcolor:[uicolor whitecolor]; }//Unified Setup Status bar- (void) Setstatusbar: (UIApplication *) application{//set the status bar to white   Application.statusbarstyle = uistatusbarstylelightcontent;  // set status bar to display after program startup (note To add View controller-based status bar appearance in the Info.plist file as No and Check the Hide status bar option of the program (this option is checked in the program General)) Application.statusbarhidden = NO;}- (void) Applicationwillresignactive: (UIApplication *) Application {//Sent when the application are about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as a incoming phone call or SMS message) or when the US    Er quits the application and it begins the transition to the background state. //Use the This method to the pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.}- (void) Applicationdidenterbackground: (UIApplication *) Application {//Use the method to release the shared resources, save user data, invalidate timers, and store enough application state in    Formation to the restore your application to the it is terminated later. //If Your application supports background execution, this method is called instead of Applicationwillterminate:when th E user quits.}- (void) Applicationwillenterforeground: (UIApplication *) Application {//Called as part of the transition from the background to the inactive state; Here you can undo many of the changes mad E on entering the background.}- (void) Applicationdidbecomeactive: (UIApplication *) Application {//Restart Any tasks this were paused (or not yet started) while the application is inactive. If the application is previously in the background, optionally refresh the user interface.}- (void) Applicationwillterminate: (UIApplication *) Application {//Called when the application are about to terminate. Save data if appropriate. See also Applicationdidenterbackground:.}@end

Unified set navigation bar and status bar code

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.