UIBarAppearance
http://www.reibang.com/p/63feddc18561
設(shè)置導(dǎo)航欄樣色
#-------設(shè)置導(dǎo)航欄不半透明脐嫂,從導(dǎo)航欄下面開始算起點(diǎn) 重要 控制器都要這么設(shè)置
self.navigationController.navigationBar.translucent = NO;
#-------設(shè)置中部文字屬性
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
#-------設(shè)置返回文字顏色
[self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
#-------修改NavigationBar背景顏色為orangeColor
[self.navigationController.navigationBar setBarTintColor:[UIColor orangeColor]];
#-------修改NavigationBar的背景圖片
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"Bar_bg"] forBarMetrics:UIBarMetricsDefault];
#-------設(shè)置為沒有毛玻璃效果,view Controller背景為lightGray
[self.navigationController.navigationBar setTranslucent:NO];
#-------去除導(dǎo)航欄底部線嘁锯,在iOS 10 這樣寫會(huì)有問題,當(dāng)導(dǎo)航欄顏色和下面接壤的顏色為同個(gè)顏色盔沫,系統(tǒng)自動(dòng)出現(xiàn)黑色線焰扳,用下面2句代碼比較妥
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
#-------設(shè)置導(dǎo)航欄item 字體大小
[self.navigationItem.rightBarButtonItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:17],NSFontAttributeName, nil] forState:UIControlStateNormal];
設(shè)置 navigationBar 的 setBackgroundImage 控制器會(huì)向下偏移 64
http://www.reibang.com/p/9a413405b253
UINavigationBar樣式
http://www.reibang.com/p/f7f48ccab1d8
iOS狀態(tài)欄的相關(guān)設(shè)置
http://www.reibang.com/p/46027d842db2
http://www.reibang.com/p/1dd3a2aec890
自定義返回按鈕
https://blog.csdn.net/xuzenghuifeng/article/details/78875611
https://blog.csdn.net/Mango_ios/article/details/70155599
https://blog.csdn.net/qq_31810357/article/details/78364336
去掉導(dǎo)航欄UINavigationBar最下面的黑線
http://www.reibang.com/p/202afecc7a9c
導(dǎo)航欄按鈕位置偏移
https://github.com/spicyShrimp/UINavigation-SXFixSpace
第三方
https://github.com/rickytan/RTRootNavigationController
https://github.com/telly/TLYShyNavBar
在UIViewController中設(shè)置title與navigationItem.title的區(qū)別
http://www.reibang.com/p/85e513aed038
設(shè)置狀態(tài)欄顏色為白色
http://blog.csdn.net/deft_mkjing/article/details/51705021
設(shè)置導(dǎo)航欄陰影線的尺寸和顏色
http://www.reibang.com/p/ff1e2ffaa152
##在 SCRootViewController,SCRootNavigationController 添加
## info.plist文件中是否有View controller-based status bar appearance 這個(gè)屬性漱办,如果有看是否為YES
-(UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
//或
self.navigationController.navigationBar.barStyle=UIBarStyleDefault; //黑色
文字按鈕
UIBarButtonItem *editItem = [[UIBarButtonItem alloc] initWithTitle:@"點(diǎn)擊" style:UIBarButtonItemStylePlain target:self action:@selector(backAction)];
self.navigationItem.rightBarButtonItem = editItem;
- (void)backAction
{
}
圖片按鈕
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
[rightButton setFrame:CGRectMake(0.0, 0.0, 44.0, 44.0)];
[rightButton addTarget:self action:@selector(Action) forControlEvents:UIControlEventTouchUpInside];
rightButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
[rightButton setImage:[UIImage imageNamed:@"xx"] forState:UIControlStateNormal];
//rightButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
self.navigationItem.rightBarButtonItem = rightItem;
- (void)Action{
}
隱藏導(dǎo)航欄
### 狀態(tài)欄顏色可能變?yōu)榘咨郏床坏?- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewWillDisappear:animated];
}
退回指定頁面
for (UIViewController *vc in self.navigationController.viewControllers) {
//返回到購物車界面
if ([vc isKindOfClass:[MJShoppingCarVC class]]) {
[self.navigationController popToViewController:vc animated:YES];
}
}
模態(tài)視圖推送
[self presentViewController:VC animated:YES completion:^{}];
[self dismissViewControllerAnimated:YES completion:^{}];
###導(dǎo)航欄包裹
YZGRootNavigationController *nav = [[YZGRootNavigationController alloc] initWithRootViewController:[KViewController new]];
設(shè)置CGRectZero從導(dǎo)航欄下開始計(jì)算
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = RGB(235, 235, 241);
//設(shè)置CGRectZero從導(dǎo)航欄下開始計(jì)算
if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)])
{
self.edgesForExtendedLayout = UIRectEdgeNone;
}
}