导航栏设置

//导航栏按钮设置

//导航栏背景色全局设置(写在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);

你可能感兴趣的:(导航栏设置)