AddRemarkView.swift 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // AddRemarkView.swift
  3. // ADHTuanCan
  4. //
  5. // Created by 敖德亨 on 2023/10/30.
  6. //
  7. import UIKit
  8. class AddRemarkView: UIView {
  9. @IBOutlet weak var blackView: UIView!
  10. @IBOutlet weak var titleLab: UILabel!
  11. @IBOutlet weak var remarkTextView: UITextView!
  12. var dataModel : MealFoodMsgModel?
  13. @IBAction func cancelAction(_ sender: UIButton) {
  14. self.hidden()
  15. }
  16. @IBAction func sureAction(_ sender: UIButton) {
  17. self.dataModel?.comment = self.remarkTextView.text
  18. self.hidden()
  19. }
  20. /// 展示
  21. public func showWithString(model : MealFoodMsgModel!){
  22. self.dataModel = model
  23. self.titleLab.text = LanguagesUtil.createTextBy(Ctext: "为\(model.name ?? "")添加备注", Etext: "Add remarks for \(model.name ?? "")")
  24. self.remarkTextView.text = "\(model.comment ?? "")"
  25. self.remarkTextView.becomeFirstResponder()
  26. kAppDelegateWindow.addSubview(self)
  27. self.blackView.alpha = 0
  28. self.frame = CGRect.init(x: 0, y: kSCREEN_HEIGHT, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
  29. UIView.animate(withDuration: 0.5) {
  30. self.frame = CGRect.init(x: 0, y: 0, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
  31. self.layoutIfNeeded()
  32. }
  33. DELAY(0.5) {
  34. self.blackView.alpha = 0.3
  35. }
  36. }
  37. /// 隐藏
  38. public func hidden(){
  39. self.blackView.alpha = 0
  40. UIView.animate(withDuration: 0.5) {
  41. self.frame = CGRect.init(x: 0, y: kSCREEN_HEIGHT, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
  42. self.layoutIfNeeded()
  43. }
  44. DELAY(0.5) {
  45. self.removeFromSuperview()
  46. }
  47. }
  48. }