1. 程式人生 > >Swift 4.0 建立導航

Swift 4.0 建立導航

AppDelegate.swift中

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
       //定義viewcontrol常量
       let vc=ViewController()
       //定義一個nav常量將檢視新增進去
       let nav=UINavigationController(rootViewController: vc)
       //將nav新增
     self.window?.rootViewController=nav
     //導航顏色
     self.window?.backgroundColor=UIColor.white
        return true
    }