EditPersonNumView.swift 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // EditPersonNumView.swift
  3. // ADHTuanCan
  4. //
  5. // Created by 敖德亨 on 2023/10/31.
  6. //
  7. import UIKit
  8. class EditPersonNumView: UIView {
  9. @IBOutlet weak var blackView: UIView!
  10. /// hud 提示
  11. lazy var hud : MCHud! = {
  12. return MCHud()
  13. }()
  14. var inputBlock : ((_ num : String)->Void)?
  15. var numStr : String?
  16. @IBOutlet weak var numTF: UITextField!
  17. override func awakeFromNib() {
  18. super.awakeFromNib()
  19. self.numTF.inputText {
  20. self.numStr = self.numTF.text
  21. }
  22. }
  23. @IBAction func sureAction(_ sender: UIButton) {
  24. self.numTF.resignFirstResponder()
  25. self.numStr = self.numTF.text
  26. if self.numStr.isEmptyStr{
  27. self.hud.showFailure(LanguagesUtil.createTextBy(Ctext: "请输入用餐人数", Etext: "Please enter the number of diners"))
  28. return
  29. }
  30. if self.inputBlock != nil{
  31. self.inputBlock!(self.numStr!)
  32. }
  33. self.hidden()
  34. }
  35. @IBAction func cancelAction(_ sender: UIButton) {
  36. self.hidden()
  37. }
  38. public func showWithNum(_ num : String){
  39. self.numTF.text = "\(num)"
  40. self.numStr = num
  41. self.numTF.becomeFirstResponder()
  42. kAppDelegateWindow.addSubview(self)
  43. self.blackView.alpha = 0
  44. self.frame = CGRect.init(x: 0, y: kSCREEN_HEIGHT, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
  45. UIView.animate(withDuration: 0.5) {
  46. self.frame = CGRect.init(x: 0, y: 0, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
  47. self.layoutIfNeeded()
  48. }
  49. DELAY(0.5) {
  50. self.blackView.alpha = 0.3
  51. }
  52. }
  53. /// 隐藏
  54. public func hidden(){
  55. self.blackView.alpha = 0
  56. UIView.animate(withDuration: 0.5) {
  57. self.frame = CGRect.init(x: 0, y: kSCREEN_HEIGHT, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
  58. self.layoutIfNeeded()
  59. }
  60. DELAY(0.5) {
  61. self.removeFromSuperview()
  62. }
  63. }
  64. }