欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2022-06-08 14:03:29
...

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
    }



链接:https://www.jianshu.com/p/47e099bc9983

相关标签: Swift