Created
December 27, 2018 04:48
-
-
Save nathantannar4/064cb8bd438c33bd838ced68a5a07f4d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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