iOS 原生导航栏 修改导航栏文字颜色 大小

2022-11-15 14:36:21 浏览数 (1)

代码语言:javascript复制
// 黑色导航栏 状态栏 
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;

self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
代码语言:javascript复制
// 白色文字
// 中间title
[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16],  NSForegroundColorAttributeName:[UIColor whiteColor]}];

// 右侧文字
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"搜索" style:UIBarButtonItemStylePlain target:self action:@selector(search:)];

    [self.navigationItem.rightBarButtonItem setTintColor:[UIColor whiteColor]];

    [self.navigationItem.rightBarButtonItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:14], NSFontAttributeName, nil] forState:UIControlStateNormal];
ios

0 人点赞