NavigationController

1.BackButton的隐藏

self.navigationItem.hidesBackButton = YES;

2.给push进去的导航栏的backButton去掉标题,只留“<” 符号

UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc]init];

backButtonItem.title = @"";

self.navigationItem.backBarButtonItem = backButtonItem;

3.自定义导航栏按钮(右)  必须给btn设置UIButtonTypeCustom

UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];

[rightBtn setFrame:CGRectMake(0, 0, 60, 22)];

[rightBtn setTitle:@"下一页" forState:UIControlStateNormal];

[rightBtn setBackgroundColor:[UIColor redColor]];

[rightBtn addTarget:self action:@selector(rightBtnClick:) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem *rightButton = [[UIBarButtonItem alloc]initWithCustomView:rightBtn];

self.navigationItem.rightBarButtonItem = rightButton;

4.导航控制器栏的背景颜色

self.navigationController.navigationBar.barTintColor = color;

5.导航栏自带按钮和按钮文字的颜色

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

6.设置导航控制器标题的颜色和字体大小等...(设置后,子控制器的标题都沿用改设置)

NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:

[UIColor whiteColor],NSForegroundColorAttributeName, [UIFont systemFontOfSize:a],NSFontAttributeName,nil];

[self.navigationController.navigationBar setTitleTextAttributes:attributes];

7.额外改变导航栏标题(越过tableItem控制器title)

self.navigationItem.title = @"CEO特训";

8.自带按钮(右)

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:nil action:@selector(rightBtn)];

推荐阅读更多精彩内容