首页 > 代码库 > IOS(Swift)使用系统UIAlertView方法做吐司效果

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

<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000 } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #cf8724 } p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; min-height: 16.0px } p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #c35900 } span.s1 { } span.s2 { color: #cf8724 } span.s3 { font: 14.0px "PingFang SC" } span.s4 { color: #36568a } span.s5 { color: #c35900 } span.s6 { color: #587ea8 } span.s7 { color: #000000 }</style>

    

   /**
     *显示弹出信息
     */
    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方法做吐司效果