杨锴
2024-11-07 62a24b3c7cf92919a93ee575e9460037e1a53816
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
59
60
61
62
63
64
65
66
67
//
//  CourseSendGiftView.swift
//  XQMuse
//
//  Created by 无故事王国 on 2024/8/19.
//
 
import UIKit
import JQTools
 
class CourseSendGiftView: UIView,JQNibView{
 
                @IBOutlet weak var btn_complete: UIButton!
                @IBOutlet weak var view_container: UIView!
                @IBOutlet weak var label_price: UILabel!
                @IBOutlet weak var cons_bottom: NSLayoutConstraint!
 
                private var price:Double = 0
 
                private var clouse:(()->Void)?
 
                override func awakeFromNib() {
                                super.awakeFromNib()
                                cons_bottom.constant = -JQ_ScreenW
                                alpha = 0
                                layoutIfNeeded()
                }
 
                static func show(price:Double,clouse:@escaping()->Void){
                                let view = CourseSendGiftView.jq_loadNibView()
        view.frame = sceneDelegate?.window?.frame ?? .zero
                                view.label_price.text = "¥\(price.jq_formatFloat)"
                                sceneDelegate?.window?.addSubview(view)
                                view.clouse = clouse
                                view.cons_bottom.constant = 0
                                UIView.animate(withDuration: 0.4) {
                                                view.alpha = 1
                                                view.layoutIfNeeded()
                                }
                }
 
                override func layoutSubviews() {
                                super.layoutSubviews()
        btn_complete.localGradientColor(cornerRadius: 18.5,bounds: CGRect(x: 0, y: 0, width: JQ_ScreenW - 46 * 2, height: 40))
                }
 
                @IBAction func completeAction(_ sender: UIButton) {
                                cons_bottom.constant = -JQ_ScreenW
                                UIView.animate(withDuration: 0.4) {
                                                self.alpha = 0
                                                self.layoutIfNeeded()
                                }completion: { _ in
                                                self.removeFromSuperview()
                                                self.clouse?()
                                }
                }
 
                @IBAction func cancelAction(_ sender: UIButton) {
                                cons_bottom.constant = -JQ_ScreenW
                                UIView.animate(withDuration: 0.4) {
                                                self.alpha = 0
                                                self.layoutIfNeeded()
                                }completion: { _ in
                                                self.removeFromSuperview()
                                }
                }
}