Last active
February 22, 2017 10:44
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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