欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

iOS 修改导航条样式

程序员文章站 2022-07-13 15:54:18
...
//导航条样式
#import "UINavigationBar+Awesome.h"

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    
    //清空 导航栏背景颜色
    [self.navigationController.navigationBar lt_reset];
    //清空 返回按钮颜色
    self.navigationController.navigationBar.tintColor =  nil;
    //清空 标题颜色
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor blackColor],NSFontAttributeName: [UIFont systemFontOfSize:16]}];
    
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    
    self.view.backgroundColor = RGBACOLOR(66, 170, 250, 1.0);
    
    //导航栏背景颜色
    [self.navigationController.navigationBar lt_setBackgroundColor:[UIColor clearColor]];
    
    // 去掉导航条下边的线
    self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];

    //返回按钮颜色
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    //标题颜色
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor],NSFontAttributeName: [UIFont systemFontOfSize:16]}];
}

参考:https://github.com/ltebean/LTNavigationBar