Created
July 20, 2018 13:41
-
-
Save enigmatic7earth/0f4d1e36db678af60990b23e323d8ada to your computer and use it in GitHub Desktop.
Autodismiss alert
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
// the alert view | |
let alert = UIAlertController(title: "", message: "alert disappears after 5 seconds", preferredStyle: .alert) | |
self.present(alert, animated: true, completion: nil) | |
// change to desired number of seconds (in this case 5 seconds) | |
let when = DispatchTime.now() + 5 | |
DispatchQueue.main.asyncAfter(deadline: when){ | |
// your code with delay | |
alert.dismiss(animated: true, completion: nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment