杨锴
3 天以前 876bce3064536c036112dd1834fb0d0013a57d16
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
//
//  CommonInputView.swift
//  DolphinEnglishLearnManager
//
//  Created by 无故事王国 on 2024/5/20.
//
 
import UIKit
 
class CommonInputView: UIView,JQNibView {
 
                @IBOutlet weak var view_container: UIView!
                @IBOutlet weak var label_title: UILabel!
                @IBOutlet weak var label_hint: UILabel!
                @IBOutlet weak var tf_input: UITextField!
                private var clouse:((String)->Void)!
 
                override func awakeFromNib() {
                                super.awakeFromNib()
                                self.alpha = 0
                                view_container.transform = .init(scaleX: 0.1, y: 0.1)
                                layoutIfNeeded()
                }
 
                static func show( _ title:String,hintTitle:String,clouse:@escaping (String)->Void){
                                let commonAlertView = CommonInputView.jq_loadNibView()
                                sceneDelegate?.window?.addSubview(commonAlertView)
                                commonAlertView.label_title.text = title
                                commonAlertView.label_hint.text = hintTitle
                                commonAlertView.clouse = clouse
                                commonAlertView.frame = sceneDelegate?.window?.frame ?? .zero
 
                                UIView.animate(withDuration: 0.4) {
                                                commonAlertView.alpha = 1
                                                commonAlertView.view_container.transform = .init(translationX: 1.0, y: 1.0)
                                                commonAlertView.layoutIfNeeded()
                                }
                }
 
                @IBAction func closeAction(_ sender: UIButton) {
                                UIView.animate(withDuration: 0.4) {
                                                self.alpha = 0
                                                self.view_container.transform = .init(scaleX: 0.1, y: 0.1)
                                } completion: { _ in
                                                self.removeFromSuperview()
                                }
                }
 
                @IBAction func completeAction(_ sender: UIButton) {
 
                                guard !tf_input.text!.isEmpty else {
                                                alertError(msg: "请输入");return
                                }
                                let text = tf_input.text!
 
                                UIView.animate(withDuration: 0.4) {
                                                self.alpha = 0
                                                self.view_container.transform = .init(scaleX: 0.1, y: 0.1)
                                } completion: { _ in
                                                self.removeFromSuperview()
                                                self.clouse(text)
                                }
                }
}