导航

一、导航方式:

把一个视图堆叠在另一个上,加上返回按钮。这种结构层次叫作 导航栈[Stack]

二、push:

let detailTVC = DetailTableViewController()
self.navigationController?.pushViewController(detailTVC, animated: true)

三、iOS的UI组件外观批量设置

可以使用Appearance API来定制大多数UI控件的外观,通过appearance代理机制来实现

更改导航条的背景及字体
 UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white, NSAttributedStringKey.font: UIFont(name: "Avenir-Light", size: 24.0) as Any]

or

let dict:NSDictionary = [NSAttributedStringKey.foregroundColor: UIColor.white,NSAttributedStringKey.font : UIFont.boldSystemFont(ofSize: 18)]

//标题颜色
UINavigationBar.appearance().titleTextAttributes = dict as? [NSAttributedStringKey : AnyObject]
向下滑动时隐藏导航条
self.navigationController?.hidesBarsOnSwipe = true

四、状态栏颜色----局部控制 [在单独的视图中加入]

有导航时(貌似可以全局)
//变得和导航条一致
 override func viewDidAppear(_ animated: Bool) {
        self.navigationController?.navigationBar.barStyle = .black
    }
无导航时
override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
    }

五、状态栏颜色----全局控制

无导航栏时
//在AppDelegate的didFinishLaunchingWithOptions方法中加入
UIApplication.shared.statusBarStyle = .lightContent

你可能感兴趣的:(导航)