OOAttandanceSettingDataView.swift 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // OOAttandanceSettingDataView.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 2018/5/18.
  6. // Copyright © 2018年 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. import CocoaLumberjack
  10. class OOAttandanceSettingDataView: UIView {
  11. @IBOutlet weak var workPlaceNameTextField: UITextField!
  12. @IBOutlet weak var workAliasNameTextField: UITextField!
  13. @IBOutlet weak var checkErrorRangeTextField: UITextField!
  14. private lazy var closwBtn:UIToolbar = {
  15. let bar = UIToolbar.init(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: 44))
  16. let button = UIButton.init(frame: CGRect(x: 50, y: 7, width: 160, height: 30))
  17. button.setTitle("保存地点", for: .normal)
  18. button.setTitleColor(UIColor.white, for: .normal)
  19. button.theme_backgroundColor = ThemeColorPicker(keyPath: "Base.base_color")
  20. button.layer.cornerRadius = 5
  21. button.layer.masksToBounds = true
  22. button.addTarget(self, action: #selector(submitClicked(_:)), for: .touchUpInside)
  23. // bar.addSubview(button)
  24. let button1 = UIButton.init(frame: CGRect(x: SCREEN_WIDTH - 60, y: 7, width: 50, height: 30))
  25. button1.setTitle("关闭", for: .normal)
  26. button1.theme_setTitleColor(ThemeColorPicker(keyPath: "Base.base_color"), forState: .normal)
  27. button1.addTarget(self, action: #selector(closwBtnClick(_:)), for: .touchUpInside)
  28. // bar.addSubview(button1)
  29. bar.items = [UIBarButtonItem(customView: button),
  30. UIBarButtonItem(customView: button1)
  31. // UIBarButtonItem(title: "保存地点", style: .plain, target: self, action: #selector(submitClicked(_:))),
  32. // UIBarButtonItem(title: "关闭", style: .plain, target: self, action: #selector(closwBtnClick(_:))),
  33. ]
  34. return bar
  35. }()
  36. override func awakeFromNib() {
  37. workPlaceNameTextField.inputAccessoryView = closwBtn
  38. workAliasNameTextField.inputAccessoryView = closwBtn
  39. checkErrorRangeTextField.inputAccessoryView = closwBtn
  40. }
  41. @objc private func submitClicked(_ sender:Any?){
  42. DDLogDebug("submitClicked")
  43. superview?.endEditing(true)
  44. let someValues = (workPlaceNameTextField.text!,workAliasNameTextField.text!,checkErrorRangeTextField.text!)
  45. NotificationCenter.post(customeNotification: .newWorkPlace, object: someValues)
  46. }
  47. @objc private func closwBtnClick(_ sender:Any?){
  48. DDLogInfo("closeBtn")
  49. superview?.endEditing(true)
  50. }
  51. }