123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- //
- // PswPayView.swift
- // ADHTuanCan
- //
- // Created by 敖德亨 on 2023/11/9.
- //
- import UIKit
- class PswPayView: UIView {
- @IBOutlet weak var blackView: UIView!
-
- @IBOutlet weak var priceLab: UILabel!
-
- @IBOutlet weak var pswT1: UITextField!
-
- @IBOutlet weak var pswT2: UITextField!
-
- @IBOutlet weak var pswT3: UITextField!
-
- @IBOutlet weak var pswT4: UITextField!
-
- @IBOutlet weak var pswT5: UITextField!
-
- @IBOutlet weak var pswT6: UITextField!
-
- var pswPayBlock : ((String?)->Void)?
-
- override func awakeFromNib() {
- super.awakeFromNib()
- // Initialization code
- pswT1.delegate = self
- pswT2.delegate = self
- pswT3.delegate = self
- pswT4.delegate = self
- pswT5.delegate = self
- pswT6.delegate = self
- pswT1.becomeFirstResponder()
- }
-
-
- @IBAction func BackAction(_ sender: UIButton) {
- self.hidden()
- }
-
- public func show(){
- self.pswT1.text = ""
- self.pswT2.text = ""
- self.pswT3.text = ""
- self.pswT4.text = ""
- self.pswT5.text = ""
- self.pswT6.text = ""
- pswT1.becomeFirstResponder()
-
- kAppDelegateWindow.addSubview(self)
- self.blackView.alpha = 0
- self.frame = CGRect.init(x: 0, y: kSCREEN_HEIGHT, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
- UIView.animate(withDuration: 0.5) {
- self.frame = CGRect.init(x: 0, y: 0, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
- self.layoutIfNeeded()
- }
- DELAY(0.5) {
- self.blackView.alpha = 0.3
- }
- }
- /// 隐藏
- public func hidden(){
- self.blackView.alpha = 0
- UIView.animate(withDuration: 0.5) {
- self.frame = CGRect.init(x: 0, y: kSCREEN_HEIGHT, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
- self.layoutIfNeeded()
- }
- DELAY(0.5) {
- self.removeFromSuperview()
- }
- }
-
- func isPstWorkOK(){
- if (pswT1.text?.count ?? 0) == 1 && (pswT2.text?.count ?? 0) == 1 && (pswT3.text?.count ?? 0) == 1 && (pswT4.text?.count ?? 0) == 1 && (pswT5.text?.count ?? 0) == 1 && (pswT6.text?.count ?? 0) == 1{
- if self.pswPayBlock != nil{
- self.pswPayBlock!("\(pswT1.text ?? "")\(pswT2.text ?? "")\(pswT3.text ?? "")\(pswT4.text ?? "")\(pswT5.text ?? "")\(pswT6.text ?? "")")
- }
- self.hidden()
- }
-
- }
- }
- extension PswPayView : UITextFieldDelegate{
-
- func textFieldDidEndEditing(_ textField: UITextField) {
- textField.layer.borderColor = UIColor.clear.cgColor
- }
-
- func textFieldDidBeginEditing(_ textField: UITextField) {
- textField.layer.borderColor = kThemeColor.cgColor
- }
-
- func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
- if string == "\n" || string == ""{
- return true
- }
- if string.count == 0{
- return true
- }
- if string.count == 1{
- if textField.text?.count == 0{
- textField.text = string
- }
- if textField == pswT1{
- self.isPstWorkOK()
- pswT2.becomeFirstResponder()
- }
- if textField == pswT2{
- self.isPstWorkOK()
- pswT3.becomeFirstResponder()
- }
- if textField == pswT3{
- self.isPstWorkOK()
- pswT4.becomeFirstResponder()
- }
- if textField == pswT4{
- self.isPstWorkOK()
- pswT5.becomeFirstResponder()
- }
- if textField == pswT5{
- self.isPstWorkOK()
- pswT6.becomeFirstResponder()
- }
- if textField == pswT6{
- self.isPstWorkOK()
- }
- return false
- }
- return false
- }
-
-
- }
|