杨锴
2024-11-06 63f7ed967433acee3ae8764c7a077e15c29c41f2
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
//
//  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.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.jq_gradientNibColor(colorArr: [UIColor(hexStr: "#8EA47A").cgColor,UIColor(hexStr: "#AFCA98").cgColor], cornerRadius: 18.5)
                }
 
                @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()
                                }
                }
}