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
52
53
54
55
56
57
58
//
//  AgreentView.swift
//  WanPai
//
//  Created by 杨锴 on 2023/6/7.
//
 
import UIKit
import JQTools
 
class AgreentView: UIView,JQNibView{
    
    enum AgreentType {
        case user
        case safe
        case privacy
    }
 
    @IBOutlet weak var view_container: UIView!
    @IBOutlet weak var bottom_cons: NSLayoutConstraint!
    private var type:AgreentType!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        bottom_cons.constant = -(JQ_ScreenH - JQ_ScreenW * 0.9)
        layoutIfNeeded()
    }
    
    
    static func show(type:AgreentType){
        let alertView = AgreentView.jq_loadNibView()
        alertView.frame = screnDelegate?.window?.frame ?? .zero
        alertView.type = type
        screnDelegate?.window?.addSubview(alertView)
        
        alertView.bottom_cons.constant = 0
        
        UIView.animate(withDuration: 0.4) {
            alertView.layoutIfNeeded()
        }
    }
    
    
    override func layoutSubviews() {
        super.layoutSubviews()
        view_container.jq_addCorners(corner: [.topLeft,.topRight], radius: 20)
    }
    
    @IBAction func completeAction(_ sender: UIButton) {
        bottom_cons.constant = -(JQ_ScreenH - JQ_ScreenW * 0.9)
        UIView.animate(withDuration: 0.4) {
            self.layoutIfNeeded()
            self.alpha = 0
        }completion: { _ in
            self.removeFromSuperview()
        }
    }
}