Skip to content

Instantly share code, notes, and snippets.

@Erkened
Last active February 22, 2017 10:44
Show Gist options
  • Save Erkened/f92c2750b0da0d3b3cd4 to your computer and use it in GitHub Desktop.
Save Erkened/f92c2750b0da0d3b3cd4 to your computer and use it in GitHub Desktop.
How to programmatically create the initial view controller, window etc. Swift 3.0
//
// AppDelegate.swift
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let navController = UINavigationController(rootViewController: ViewController()) // ViewController is the initial view controller
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
// Setup the project automatically.
// Remember to remove the key-value pair for key "Main storyboard file base name" from Info.plist
// Delete the storyboard file Main.storyboard
window = UIWindow(frame: UIScreen.main.bounds)
guard let window = window else{
return false
}
navController.isNavigationBarHidden = true // Hide the navigation bar
window.backgroundColor = UIColor.white
window.rootViewController = navController
window.makeKeyAndVisible()
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment