美文网首页IOS
iOS swift设置导航栏(navigationBar)背景颜

iOS swift设置导航栏(navigationBar)背景颜

作者: ioido | 来源:发表于2018-01-30 17:31 被阅读788次

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
    }

相关文章

网友评论

本文标题:iOS swift设置导航栏(navigationBar)背景颜

本文链接:https://www.haomeiwen.com/subject/cjwczxtx.html