Skip to content

Instantly share code, notes, and snippets.

@nathantannar4
Created December 27, 2018 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathantannar4/064cb8bd438c33bd838ced68a5a07f4d to your computer and use it in GitHub Desktop.
Save nathantannar4/064cb8bd438c33bd838ced68a5a07f4d to your computer and use it in GitHub Desktop.
import UIKit
class Controller<RootViewType: IView>: UIViewController {
var rootView: RootViewType! {
return view as? RootViewType
}
// MARK: - View Life Cycle
override func loadView() {
view = RootViewType(frame: UIScreen.main.bounds)
view.setNeedsLayout()
view.layoutIfNeeded()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
rootView.viewWillAppear(animated)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
rootView.viewDidAppear(animated)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
rootView.viewWillDisappear(animated)
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
rootView.viewDidDisappear(animated)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment