Skip to content

Instantly share code, notes, and snippets.

@Inndy
Created April 30, 2017 06:26
Show Gist options
  • Save Inndy/85150e4b708ee6a99f71760adda602b9 to your computer and use it in GitHub Desktop.
Save Inndy/85150e4b708ee6a99f71760adda602b9 to your computer and use it in GitHub Desktop.
iOS create overlay with UIWindow
import UIKit
class RecordViewController: UIViewController {
@IBAction func closeOverlay(_ sender: Any) {
self.view.window?.resignKey()
self.view.window?.isHidden = true
}
}
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