Displaying a message in iOS which has the same functionality as Toast in Android

前端 未结 19 1730
逝去的感伤
逝去的感伤 2020-12-12 12:35

I need to know if there is any method in iOS which behaves like Toast messages in Android. That is, I need to display a message which is dismissed automatically after few se

19条回答
  •  悲&欢浪女
    2020-12-12 13:27

    If you want one with iOS Style, download this framework from Github

    iOS Toast Alert View Framework

    This examples work on you UIViewController, once you imported the Framework.

    Example 1:

    //Manual 
    let tav = ToastAlertView()
    tav.message = "Hey!"
    tav.image = UIImage(named: "img1")!
    tav.show()
    //tav.dismiss() to Hide
    

    Example 2:

    //Toast Alert View with Time Dissmis Only
    self.showToastAlert("5 Seconds",
                    image: UIImage(named: "img1")!,
                    hideWithTap: false,
                    hideWithTime: true,
                    hideTime: 5.0)
    

    Final:

提交回复
热议问题