Created
April 30, 2017 06:26
-
-
Save Inndy/85150e4b708ee6a99f71760adda602b9 to your computer and use it in GitHub Desktop.
iOS create overlay with UIWindow
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
import UIKit | |
class RecordViewController: UIViewController { | |
@IBAction func closeOverlay(_ sender: Any) { | |
self.view.window?.resignKey() | |
self.view.window?.isHidden = true | |
} | |
} |
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
import UIKit | |
class ViewController: UIViewController { | |
var window: UIWindow? | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
window = UIWindow(frame: self.view.bounds) | |
window?.backgroundColor = UIColor(colorLiteralRed: 0, green: 0, blue: 0, alpha: 0.3) | |
window?.rootViewController = storyboard!.instantiateViewController(withIdentifier: "RecordOverlay") | |
} | |
@IBAction func openOverlay(_ sender: Any) { | |
window?.makeKeyAndVisible() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment