From 24182a847205ad81c759a0d173cc0e12fcd5a149 Mon Sep 17 00:00:00 2001 From: r <r@gmail.com> Date: 星期五, 29 八月 2025 17:05:00 +0800 Subject: [PATCH] fixbug --- WanPai/Common/View/CommonAlertView.swift | 34 +++++++++++++++++++++++++++------- 1 files changed, 27 insertions(+), 7 deletions(-) diff --git a/WanPai/Common/View/CommonAlertView.swift b/WanPai/Common/View/CommonAlertView.swift index 7ec7bd6..81bf4ca 100644 --- a/WanPai/Common/View/CommonAlertView.swift +++ b/WanPai/Common/View/CommonAlertView.swift @@ -13,7 +13,9 @@ @IBOutlet weak var view_container: UIView! @IBOutlet weak var label_title: UILabel! @IBOutlet weak var label_content: UILabel! - + @IBOutlet weak var btn_cancel: UIButton! + @IBOutlet weak var btn_complete: UIButton! + private var title:String! private var content:String! private var clouse:((Bool)->Void)! @@ -26,32 +28,50 @@ } - static func show(title:String,content:String, clouse:@escaping (Bool)->Void){ + static func show(title:String,content:String,cancelStr:String? = nil,completeStr:String? = nil,isSingle:Bool = false, clouse:@escaping (Bool)->Void){ let alertView = CommonAlertView.jq_loadNibView() alertView.label_title.text = title alertView.label_content.text = content + alertView.btn_cancel.isHidden = isSingle + + + if cancelStr != nil{ + alertView.btn_cancel.setTitle(cancelStr!, for: .normal) + } + + if completeStr != nil{ + alertView.btn_complete.setTitle(completeStr!, for: .normal) + } + + alertView.clouse = clouse - alertView.frame = screnDelegate?.window?.frame ?? .zero - screnDelegate?.window?.addSubview(alertView) + alertView.frame = sceneDelegate?.window?.frame ?? .zero + sceneDelegate?.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){ + static func show(title:String,attribute:NSMutableAttributedString,isSingle:Bool = false, clouse:@escaping (Bool)->Void){ let alertView = CommonAlertView.jq_loadNibView() alertView.label_title.text = title + alertView.btn_cancel.isHidden = isSingle alertView.label_content.attributedText = attribute alertView.clouse = clouse - alertView.frame = screnDelegate?.window?.frame ?? .zero - screnDelegate?.window?.addSubview(alertView) + alertView.frame = sceneDelegate?.window?.frame ?? .zero + sceneDelegate?.window?.addSubview(alertView) UIView.animate(withDuration: 0.4) { alertView.view_container.transform = .init(scaleX: 1.0, y: 1.0) alertView.alpha = 1 } } + override func layoutSubviews() { + super.layoutSubviews() + btn_complete.localGradientColor(cornerRadius: 20) + } + @IBAction func closeAction(_ sender: UIButton) { UIView.animate(withDuration: 0.4) { -- Gitblit v1.7.1