Skip to content

Instantly share code, notes, and snippets.

@abhimuralidharan
Last active October 27, 2020 12:31
Show Gist options
  • Save abhimuralidharan/507e311335a150453fcb275c66404b5a to your computer and use it in GitHub Desktop.
Save abhimuralidharan/507e311335a150453fcb275c66404b5a to your computer and use it in GitHub Desktop.
toast in swift for debugging
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