1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- //
- // EditPersonNumView.swift
- // ADHTuanCan
- //
- // Created by 敖德亨 on 2023/10/31.
- //
- import UIKit
- class EditPersonNumView: UIView {
-
- @IBOutlet weak var blackView: UIView!
- /// hud 提示
- lazy var hud : MCHud! = {
- return MCHud()
- }()
-
- var inputBlock : ((_ num : String)->Void)?
-
- var numStr : String?
-
- @IBOutlet weak var numTF: UITextField!
-
- override func awakeFromNib() {
- super.awakeFromNib()
-
- self.numTF.inputText {
- self.numStr = self.numTF.text
- }
-
- }
-
- @IBAction func sureAction(_ sender: UIButton) {
- self.numTF.resignFirstResponder()
- self.numStr = self.numTF.text
- if self.numStr.isEmptyStr{
- self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请输入用餐人数", Etext: "Please enter the number of diners"))
- return
- }
-
- if self.inputBlock != nil{
- self.inputBlock!(self.numStr!)
- }
- self.hidden()
- }
-
- @IBAction func cancelAction(_ sender: UIButton) {
- self.hidden()
- }
-
- public func showWithNum(_ num : String){
- self.numTF.text = "\(num)"
- self.numStr = num
- self.numTF.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()
- }
- }
- }
|