younger_times
2023-06-14 177ae5f9f619bd39e2d505709d8c5b419e7867ee
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
//
//  CityChooseSubTypeView.swift
//  WanPai
//
//  Created by 杨锴 on 2023/6/13.
//
 
import UIKit
import JQTools
 
class CityChooseSubTypeView: UIView,JQNibView{
    @IBOutlet weak var cons_viewHeight: NSLayoutConstraint!
    private var closeClouse:(()->Void)?
    private var clouse:((String)->Void)?
    
    override func awakeFromNib() {
        super.awakeFromNib()
        cons_viewHeight.constant = 100
        alpha = 0
        layoutIfNeeded()
    }
    
    
    static func show(inView:UIView,afterView:UIView,clouse:@escaping (String)->Void,closeClouse:@escaping ()->Void){
        let subTypeView = CityChooseSubTypeView.jq_loadNibView()
        subTypeView.closeClouse = closeClouse
        subTypeView.clouse = clouse
        inView.addSubview(subTypeView)
        subTypeView.snp.makeConstraints { make in
            make.top.equalTo(afterView.snp.bottom)
            make.left.right.bottom.equalToSuperview()
        }
        
        UIView.animate(withDuration: 0.2) {
            subTypeView.alpha = 1
        } completion: { _ in
            subTypeView.cons_viewHeight.constant = JQ_ScreenH - 175  - UIDevice.jq_safeEdges.top - JQ_NavBarHeight
            UIView.animate(withDuration: 0.2) {
                subTypeView.layoutIfNeeded()
            }
        }
    }
    
    
    @IBAction func closeAction(_ sender: UIButton) {
        self.cons_viewHeight.constant = 100
        UIView.animate(withDuration: 0.2) {
            self.alpha = 0
            self.layoutIfNeeded()
        } completion: { _ in
            self.removeFromSuperview()
            self.closeClouse!()
        }
    }
}