IOS Swift 3/4 show alert for specific time duration

   let alert = UIAlertController(title: "", message: "alert disappears after 30 seconds", preferredStyle: .alert)

            self.present(alert, animated: true, completion: nil)

            // change to desired number of seconds (in this case3 0 seconds)

            let when = + 30

            DispatchQueue.main.asyncAfter(deadline: when){

                // your code with delay

                alert.dismiss(animated: true, completion: nil)


Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post