設置全局導航欄顏色,標題大小和UIBarButtonItem字體大小


 

  設置全局導航欄顏色,標題大小和UIBarButtonItem字體大小

在appdelegate里面設置

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 -  設置全局返回按鈕,無文字

    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)

                                                         forBarMetrics:UIBarMetricsDefault];

 

如果需要設置導航欄顏色,使barItem顏色也被渲染了,可以這樣設置(就可以保證barItem里面圖片的顏色不被渲染了)

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage: [[UIImage imageNamed: @"xiaoxi_icon"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal] style: UIBarButtonItemStylePlain target: self action: @selector(a)];

 

 

如果導航欄與view出現了空隙。需要把系統默認設置空隙值關掉

#pragma 設置控制器,出現默認知道空隙

//    self.automaticallyAdjustsScrollViewInsets = NO;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM