iOS swift设置导航栏(navigationBar)背景颜色,标题颜色和字体大小,item颜色

swift 4

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        window = UIWindow(frame: UIScreen.main.bounds)
        window?.backgroundColor = UIColor.white
        let nav = UINavigationController(rootViewController: HomeVC())
        //设置导航栏背景颜色
        nav.navigationBar.barTintColor = UIColor.blue
        let dict:NSDictionary = [NSAttributedStringKey.foregroundColor: UIColor.white,NSAttributedStringKey.font : UIFont.boldSystemFont(ofSize: 18)]
        //标题颜色
        nav.navigationBar.titleTextAttributes = dict as? [NSAttributedStringKey : AnyObject]
        //item颜色
        nav.navigationBar.tintColor = UIColor.gray
        window?.rootViewController = nav
        window?.makeKeyAndVisible()
        return true
    }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容