Last active
October 27, 2020 12:31
-
-
Save abhimuralidharan/507e311335a150453fcb275c66404b5a to your computer and use it in GitHub Desktop.
toast in swift for debugging
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
extension UIViewController { | |
public func showToast(message : String, seconds: Double = 1.0) { | |
let toast = UIAlertController(title: nil, message: message, preferredStyle: .alert) | |
toast.view.alpha = 0.5 | |
present(toast, animated: true) | |
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + seconds) { | |
toast.dismiss(animated: true) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment