修改UINavigationController,UINavigationBar背景颜色,字体颜色

时间:2021-07-07 07:12:26




- (void)setNav

{

    UINavigationBar *bar = [UINavigationBarappearance];

    //设置显示的颜色

    bar.barTintColor = [UIColorcolorWithRed:62/255.0green:173/255.0blue:176/255.0alpha:1.0];

    //设置字体颜色

    bar.tintColor = [UIColorwhiteColor];

    [bar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColorwhiteColor]}];

//或者用这个都行

//    [bar setTitleTextAttributes:@{UITextAttributeTextColor : [UIColorwhiteColor]}];


}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {


//*********

[self setNav];//修改程序中所有的显示的navigationbar的颜色,字体


//********

}


如图


修改UINavigationController,UINavigationBar背景颜色,字体颜色