IOS(Swift)使用系统UIAlertView方法做吐司效果

Posted mapanguan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IOS(Swift)使用系统UIAlertView方法做吐司效果相关的知识,希望对你有一定的参考价值。

    

   /**
     *显示弹出信息
     */
    class func showAlertMessage(_ str:String,showtime Num:Double){
        
        let alert = UIAlertView(title: str, message: nil, delegate: nil, cancelButtonTitle: nil);
        alert.show()
        //        self.performSelector(#selector(dismissAlert(_:)), withObject: alert, afterDelay: Num)
        let dispatchTime: DispatchTime = DispatchTime.now() + Double(Int64(0.10 * Num * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
        DispatchQueue.main.asyncAfter(deadline: dispatchTime, execute: {
            dismissAlert(alert)
        })
    }
    
    class func dismissAlert(_ alert:UIAlertView){
        alert.dismiss(withClickedButtonIndex: alert.cancelButtonIndex, animated: true)
    }

  

以上是关于IOS(Swift)使用系统UIAlertView方法做吐司效果的主要内容,如果未能解决你的问题,请参考以下文章

iOS Swift:如何创建像 UIAlertView 这样看似在解雇后自行消失的对象

为 iOS 7.1 编程并使用 UIAlertView,这是不是也适用于 iOS 8.0?

UIAlertView 和 UIAlertController

iOS系统自带的 UIAlertView 自动旋转的实现

如何在 Swift 中创建 UIAlertView?

RMUniversalAlert 的错误 - UIAlertView+Blocks/UIAlertView+Blocks.h 未找到