From 66e7071aa076b7eac9d6bb431857af5be63a2680 Mon Sep 17 00:00:00 2001 From: 无故事王国 <841720330@qq.com> Date: 星期四, 29 六月 2023 18:40:21 +0800 Subject: [PATCH] 使用福利UI --- WanPai/Common/View/CommonAlertView.swift | 31 +++++++++++++++++++++++++++++-- 1 files changed, 29 insertions(+), 2 deletions(-) diff --git a/WanPai/Common/View/CommonAlertView.swift b/WanPai/Common/View/CommonAlertView.swift index 245c450..7ec7bd6 100644 --- a/WanPai/Common/View/CommonAlertView.swift +++ b/WanPai/Common/View/CommonAlertView.swift @@ -16,6 +16,7 @@ private var title:String! private var content:String! + private var clouse:((Bool)->Void)! override func awakeFromNib() { super.awakeFromNib() @@ -25,18 +26,43 @@ } - static func show(title:String,content:String){ + static func show(title:String,content:String, clouse:@escaping (Bool)->Void){ let alertView = CommonAlertView.jq_loadNibView() alertView.label_title.text = title alertView.label_content.text = content + alertView.clouse = clouse alertView.frame = screnDelegate?.window?.frame ?? .zero screnDelegate?.window?.addSubview(alertView) UIView.animate(withDuration: 0.4) { alertView.view_container.transform = .init(scaleX: 1.0, y: 1.0) alertView.alpha = 1 } - } + + static func show(title:String,attribute:NSMutableAttributedString, clouse:@escaping (Bool)->Void){ + let alertView = CommonAlertView.jq_loadNibView() + alertView.label_title.text = title + alertView.label_content.attributedText = attribute + alertView.clouse = clouse + alertView.frame = screnDelegate?.window?.frame ?? .zero + screnDelegate?.window?.addSubview(alertView) + UIView.animate(withDuration: 0.4) { + alertView.view_container.transform = .init(scaleX: 1.0, y: 1.0) + alertView.alpha = 1 + } + } + + + @IBAction func closeAction(_ sender: UIButton) { + UIView.animate(withDuration: 0.4) { + self.view_container.transform = .init(scaleX: 0.1, y: 0.1) + self.alpha = 0 + }completion: { _ in + self.clouse!(false) + self.removeFromSuperview() + } + } + @IBAction func completeAction(_ sender: UIButton) { @@ -44,6 +70,7 @@ self.view_container.transform = .init(scaleX: 0.1, y: 0.1) self.alpha = 0 }completion: { _ in + self.clouse!(true) self.removeFromSuperview() } } -- Gitblit v1.7.1