OneViewController.swift 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // OneViewController.swift
  3. // OJASwiftKitDemo
  4. //
  5. // Created by luxiaoming on 2016/12/5.
  6. // Copyright © 2016年 luxiaoming. All rights reserved.
  7. //
  8. import UIKit
  9. import OJASwiftKit
  10. class OneViewController: OJSViewController {
  11. var testButton: UIButton!
  12. init(shouldHideNavigationBar: Bool = true) {
  13. super.init(nibName: nil, bundle: nil)
  14. ojs_shouldHideNavigationBar = shouldHideNavigationBar
  15. ojs_shouldHideCustomNavBar = false
  16. }
  17. required init?(coder aDecoder: NSCoder) {
  18. super.init(coder: aDecoder)
  19. }
  20. deinit {
  21. DLog("deinit")
  22. }
  23. }
  24. // MARK: - Lifecycle
  25. extension OneViewController {
  26. override func viewDidLoad() {
  27. super.viewDidLoad()
  28. self.title = "hello"
  29. self.view.backgroundColor = UIColor.orange
  30. // setupDefalutBackNavBarView()
  31. setupDefalutBackDismissBarView()
  32. DLog("hello")
  33. let testButton = UIButton(frame: CGRect(x: 0, y: 100, width: 100, height: 100))
  34. testButton.backgroundColor = UIColor.gray
  35. self.view.addSubview(testButton)
  36. testButton.addCallback { [unowned self] (sender) in
  37. Delay(3, closure: {
  38. self.setupDefalutBackNavBarView()
  39. })
  40. // let twoViewController = TwoViewController()
  41. // self.present(twoViewController, animated: true, completion: {
  42. //
  43. // })
  44. }
  45. self.testButton = testButton
  46. }
  47. override func didReceiveMemoryWarning() {
  48. super.didReceiveMemoryWarning()
  49. // Dispose of any resources that can be recreated.
  50. }
  51. }
  52. // MARK: - PublicMethod
  53. extension OneViewController {
  54. func setupDefalutBackNavBarView() {
  55. self.ojs_navBarView?.backgroundColor = UIColor.blue
  56. self.ojs_navBarView?.viewType = .type1_0
  57. let image = UIImage(named: "nav_back")
  58. self.ojs_navBarView?.leftOneButton.setImage(image, for: .normal)
  59. self.ojs_navBarView?.leftOneButton.addCallback { [unowned self] (sender) in
  60. let _ = self.navigationController?.popViewController(animated: true)
  61. }
  62. }
  63. func setupDefalutBackDismissBarView() {
  64. self.ojs_navBarView?.viewType = .type0_1
  65. self.ojs_navBarView?.rightOneButton.setImage(UIImage(named: "nav_close"), for: .normal)
  66. self.ojs_navBarView?.rightOneButton.addCallback { [unowned self] (sender) in
  67. self.dismiss(animated: true, completion: nil)
  68. }
  69. }
  70. }