Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lucaswkuipers/ff949b895c83a40f390165ecb5dd79a4 to your computer and use it in GitHub Desktop.
Save lucaswkuipers/ff949b895c83a40f390165ecb5dd79a4 to your computer and use it in GitHub Desktop.
import UIKit
final class ReusableViewController: UIViewController {
var didLoadView: (() -> Void?)?
var willAppearView: ((_ animated: Bool) -> Void)?
private let contentView: UIView
init(with view: UIView) {
self.contentView = view
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func loadView() {
super.loadView()
self.view = contentView
}
override func viewDidLoad() {
super.viewDidLoad()
didLoadView?()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
willAppearView?(animated)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment