LoginSignup
3
3

More than 5 years have passed since last update.

[iOS] メインWindowの上に新しくUIWindowを作成する方法

Last updated at Posted at 2018-10-02

Github

https://github.com/TakanobuSano/CreateNewUIWindow
CreateNewUIWindow.gif

メインWindowを作成


        window = UIWindow(frame: UIScreen.main.bounds)
        if nil != window {
            let viewController = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "MainID")
            window?.rootViewController = viewController
            window?.makeKeyAndVisible()
        }

新しくUIWindowを作成

チュートリアルなどを作成する際に新しくUIWindowをオーバーレイさせて実装するときに利用します。


        newWindow = UIWindow(frame: UIScreen.main.bounds)
        if nil != newWindow {
            let viewController = UIStoryboard.init(name: "NewWindow", bundle: nil).instantiateViewController(withIdentifier: "NewWindowID")
            newWindow?.rootViewController = viewController
            newWindow?.makeKeyAndVisible()
        }

新しく作成したUIWindowを削除

このとき、メインWindow側の「viewWillAppear」などはコールされませんので、
チュートリアルなどアプリの動作に影響せずに独立した形で動作するのに適しています。


self.view.window?.isHidden = true
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3