How to display temporary popup message on iPhone/iPad/iOS

后端 未结 10 1002
孤城傲影
孤城傲影 2020-12-04 11:31

I\'d like to display a temporary message on the iPhone/iPad displaying confirmation of an action, or some quick status about some background activity.

Is there a st

10条回答
  •  一个人的身影
    2020-12-04 12:16

    This is just a Swift 3 version of user2234810 2.2 version.

    func showPopupWithTitle(title: String, message: String, interval: TimeInterval) {
        let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
        present(alertController, animated: true, completion: nil)
        self.perform(#selector(dismissAlertViewController), with: alertController, afterDelay: interval)
    }
    
    func dismissAlertViewController(alertController: UIAlertController) {
        alertController.dismiss(animated: true, completion: nil)
    }
    showPopupWithTitle(title: "Title", message: "Message", interval: 0.5)
    

提交回复
热议问题