In my app I want to create a new UIWindow
over the main UIWindow, And I wrote as following, but it don\'t works.
first, i create a UIWindow
as the
Swift 4
To avoid memory leak, I prefer to initialise my custom window in this way, as proposed by Apple :
If you want to provide a custom window for your app, you must implement the getter method of this property and use it to create and return your custom window.
Example:
var myCustomWindow: UIWindow? = CustomWindow(frame: UIScreen.main.bounds)
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let mainController: MainViewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController() as! MainViewController
self.myCustomWindow?.rootViewController = mainController
self.myCustomWindow?.makeKeyAndVisible()
}