美文网首页
swift alertView的写法及一些宏定义

swift alertView的写法及一些宏定义

作者: 艾尔之光_熊 | 来源:发表于2018-01-17 18:59 被阅读0次

    //提示弹窗消息并自动消失方法

     func showAlertMessage(message:NSString?, duration:Float){

                let alertController = UIAlertController(title: "", message: message as String?,preferredStyle:.alert)

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

                self.perform(#selector(dimissAlert), with: alertController, afterDelay: TimeInterval(duration))

        }

    @objc func dimissAlert(alert:UIAlertController) {

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

    }

    一些简单的宏定义

    let ScreenHeight:CGFloat = UIScreen.main.bounds.size.height//屏幕高度

    let ScreenWidth:CGFloat = UIScreen.main.bounds.size.width//屏幕宽度

    let NavigationHeight = (ScreenHeight == 812.0) ? 88 : 64//判断是否iPhone X,返回不同的导航栏高度

    相关文章

      网友评论

          本文标题:swift alertView的写法及一些宏定义

          本文链接:https://www.haomeiwen.com/subject/jgwuoxtx.html