younger_times
2023-06-09 221256d53c43f2d768748d6018ffddf1f23d65b9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
//  CommonAlertView.swift
//  WanPai
//
//  Created by 杨锴 on 2023/6/7.
//
 
import UIKit
import JQTools
 
class CommonAlertView: UIView,JQNibView{
 
    @IBOutlet weak var view_container: UIView!
    @IBOutlet weak var label_title: UILabel!
    @IBOutlet weak var label_content: UILabel!
    
    private var title:String!
    private var content:String!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        view_container.transform = .init(scaleX: 0.1, y: 0.1)
        alpha = 0
        layoutIfNeeded()
    }
    
    
    static func show(title:String,content:String){
        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)
        UIView.animate(withDuration: 0.4) {
            alertView.view_container.transform = .init(scaleX: 1.0, y: 1.0)
            alertView.alpha = 1
        }
        
    }
    
    
    @IBAction func completeAction(_ sender: UIButton) {
        UIView.animate(withDuration: 0.4) {
            self.view_container.transform = .init(scaleX: 0.1, y: 0.1)
            self.alpha = 0
        }completion: { _ in
            self.removeFromSuperview()
        }
    }
    
}