Skip to content

Instantly share code, notes, and snippets.

@fahied
Created April 10, 2019 15:27
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 fahied/4e0744096d99bf09953772cf64704b98 to your computer and use it in GitHub Desktop.
Save fahied/4e0744096d99bf09953772cf64704b98 to your computer and use it in GitHub Desktop.
UIWindow Alert
func showAlert(message: String) {
let alert = UIAlertController(title: "Link", message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}}))
let topWindow = UIWindow(frame: UIScreen.main.bounds)
topWindow.rootViewController = UIViewController()
topWindow.windowLevel = UIWindow.Level.alert + 1
topWindow.makeKeyAndVisible()
topWindow.rootViewController?.present(alert, animated: true, completion: nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment