导航栏背景色、标题颜色以及返回键自定义
1.導航欄背景色設置:
//設置為半透明
self.navigationController.navigationBar.translucent = YES;
//設置背景色及透明度
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:0.75]] forBarMetrics:UIBarMetricsDefault];
2.導航欄標題顏色:
[self.navigationController.navigationBar setTintColor:[UIColorwhiteColor]];
3.自定義返回鍵:
UIImage *backImage = [UIImage imageNamed:@"route_tab_back"];
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[backBtn setImage:backImage forState:UIControlStateNormal];
backBtn.frame = CGRectMake(0, 0, backImage.size.width, backImage.size.height);
[backBtn addTarget:self action:@selector(handleBackButton) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
self.navigationController.navigationItem.leftBarButtonItem = item;
總結
以上是生活随笔為你收集整理的导航栏背景色、标题颜色以及返回键自定义的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一汽妈妈叫你来看跌停
- 下一篇: Mixly for Mac米思齐安装过程