• 统一设置导航栏与状态栏代码


    统一设置导航栏与状态栏代码:

    #import "AppDelegate.h"
    #import "SZMMainTabBarController.h"
    @interface AppDelegate ()
    
    @end
    
    @implementation AppDelegate
    
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
        //创建window
        self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
        
        //创建要控制器
        SZMMainTabBarController *mainVc = [[SZMMainTabBarController alloc]init];
        
        //将mainVc设置为window的根控制器
        self.window.rootViewController = mainVc;
        
        //统一设置导航栏
        [self setNavBar];
        
        //统一设置状态栏
        [self setStatusBar:application];
        //设置self.window 为主控制器并显示
        [self.window makeKeyAndVisible];
        
        return YES;
    }
    
    //统一设置导航栏
    - (void)setNavBar{
        //用appearance方法获得全局代理对象,然后对全局代理对象进行设置便设置了所有的导航栏
        UINavigationBar *NavBar = [UINavigationBar appearance];
        [NavBar setBackgroundImage:[UIImage imageNamed:@"NavBar64"] forBarMetrics:UIBarMetricsDefault];
        NSDictionary *arrtu = @{NSForegroundColorAttributeName:[UIColor whiteColor]};
        //修改导航栏中标题文字的颜色
        [NavBar setTitleTextAttributes:arrtu];
        //修改导航栏中返回按钮的颜色
        [NavBar setTintColor:[UIColor whiteColor]];
        
        
    }
    
    //统一设置状态栏
    - (void)setStatusBar:(UIApplication *)application
    {
        //设置状态栏为白色
        application.statusBarStyle = UIStatusBarStyleLightContent;
        //设置状态栏在程序启动后显示(注意要在info.plist文件中添加View controller-based status bar appearance这一项为NO 并且 将程序的hide status bar 选项勾选(此选项在程序general中勾选))
        application.statusBarHidden = NO;
    }
    
    - (void)applicationWillResignActive:(UIApplication *)application {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to 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 this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the 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 made on entering the background.
    }
    
    - (void)applicationDidBecomeActive:(UIApplication *)application {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }
    
    - (void)applicationWillTerminate:(UIApplication *)application {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }
    
    @end
  • 相关阅读:
    Elasticsearch、Logstash和Kibana Windows环境搭建(一)
    20200820--1维数组 年龄与疾病(奥赛一本通P78 5)
    20200820--1维数组 数组逆序重放(奥赛一本通P77 4)
    20200820--一维数组:与指定数字相同的数的个数(奥赛一本通P75 1)
    20200819--金币 奥赛一本通P73 10 已讲
    20200818-数1的个数(奥赛一本通 P69 5)
    bits/stdc++.h
    数1的个数(奥赛一本通 P69 5)
    函数和方法的讲解
    20200817-与7无关的数(奥赛一本通 P68 4)
  • 原文地址:https://www.cnblogs.com/ZMiOS/p/5023034.html
Copyright © 2020-2023  润新知