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)];

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

推荐阅读更多精彩内容