导航栏设置

//导航栏按钮设置

//导航栏背景色全局设置(写在appdelegate里)

[[UINavigationBar appearance] setBarTintColor:kMainColorOfApp];

//按钮标题颜色设置

[self.navigationController.navigationBar setTintColor:[UIColor blackColor]];

//按钮标题设置

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(onClickCancel)];

self.navigationItem.rightBarButtonItem =  [[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(onClickSave)];

self.navigationItem.title = @"服务地区";

修改导航条背景颜色

self.navigationController.navigationBar.barTintColor = [UIColor colorWithHexString:@"#2295f2"];

设置了导航条背景颜色,会导致按钮标题颜色改变,通过以下方法修改

self.navigationController.navigationBar.tintColor = [UIColor whiteColor];

自定义的按钮图片距屏幕边缘太远,可通过以下代码修改

系统默认的rightBarButtonItem边距

self.navigationItem.leftBarButtonItem.imageInsets = UIEdgeInsetsMake(0,-20,0,0);

self.navigationItem.rightBarButtonItem.imageInsets = UIEdgeInsetsMake(0,-10,0,10);

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容