Skip to content

Instantly share code, notes, and snippets.

@felipericieri
Last active January 18, 2020 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felipericieri/5d8e1eb97b9fdca6f3178f2ef846d456 to your computer and use it in GitHub Desktop.
Save felipericieri/5d8e1eb97b9fdca6f3178f2ef846d456 to your computer and use it in GitHub Desktop.
Change Window Root View Controller
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
// MARK: - Handling Application Background State
func applicationDidEnterBackground(_ application: UIApplication) {
let blockViewController = BlockViewController()
self.lastViewController = window?.rootViewController
window?.rootViewController = blockViewController
}
func applicationWillEnterForeground(_ application: UIApplication) {
window?.rootViewController = lastViewController
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment