无故事王国
2023-10-11 f7e33a3255d9f87b20e4a06fc32012eaad77cad5
WanPai/Common/View/CommonAlertView.swift
@@ -13,9 +13,12 @@
    @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)!
    
    override func awakeFromNib() {
        super.awakeFromNib()
@@ -25,18 +28,50 @@
    }
    
    
    static func show(title:String,content:String){
   static func show(title:String,content:String,isSingle:Bool = false, clouse:@escaping (Bool)->Void){
        let alertView = CommonAlertView.jq_loadNibView()
        alertView.label_title.text = title
        alertView.label_content.text = content
        alertView.frame = screnDelegate?.window?.frame ?? .zero
        screnDelegate?.window?.addSubview(alertView)
      alertView.btn_cancel.isHidden = isSingle
        alertView.clouse = clouse
        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,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 = 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) {
            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 +79,7 @@
            self.view_container.transform = .init(scaleX: 0.1, y: 0.1)
            self.alpha = 0
        }completion: { _ in
            self.clouse!(true)
            self.removeFromSuperview()
        }
    }