swift:
UINavigationBar.appearance().barTintColor = UIColor.init(red: 47, green: 48, blue: 52)
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName: UIFont.boldSystemFontOfSize(18),NSForegroundColorAttributeName: UIColor.whiteColor()]
UIBarButtonItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont.boldSystemFontOfSize(15),NSForegroundColorAttributeName: UIColor.whiteColor()], forState: UIControlState.Normal)
oc:
#pragma mark - 設(shè)置全局返回按鈕,無文字
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];
如果需要設(shè)置導(dǎo)航欄顏色姐军,使barItem顏色也被渲染了笛谦,可以這樣設(shè)置(就可以保證barItem里面圖片的顏色不被渲染了)
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage: [[UIImage imageNamed: @"xiaoxi_icon"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal] style: UIBarButtonItemStylePlain target: self action: @selector(a)];
如果導(dǎo)航欄與view出現(xiàn)了空隙糕殉。需要把系統(tǒng)默認(rèn)設(shè)置空隙值關(guān)掉
#pragma 設(shè)置控制器,出現(xiàn)默認(rèn)知道空隙
self.automaticallyAdjustsScrollViewInsets = NO;