Commit da9375eb by Daniel Dahan

development: updated RootController API

parent 75c4665b
...@@ -143,6 +143,7 @@ extension UINavigationItem { ...@@ -143,6 +143,7 @@ extension UINavigationItem {
} }
} }
/// Title text.
@nonobjc @nonobjc
public var title: String? { public var title: String? {
get { get {
......
...@@ -113,25 +113,27 @@ open class RootController: UIViewController { ...@@ -113,25 +113,27 @@ open class RootController: UIViewController {
the transition animation from the active rootViewController the transition animation from the active rootViewController
to the toViewController has completed. to the toViewController has completed.
*/ */
open func transitionFromRootViewController(toViewController: UIViewController, duration: TimeInterval = 0.5, options: UIViewAnimationOptions = [], animations: (() -> Void)? = nil, completion: ((Bool) -> Void)? = nil) { open func transition(to viewController: UIViewController, duration: TimeInterval = 0.5, options: UIViewAnimationOptions = [], animations: (() -> Void)? = nil, completion: ((Bool) -> Void)? = nil) {
rootViewController.willMove(toParentViewController: nil) rootViewController.willMove(toParentViewController: nil)
addChildViewController(toViewController) addChildViewController(viewController)
toViewController.view.frame = rootViewController.view.bounds viewController.view.frame = rootViewController.view.bounds
transition(from: rootViewController, transition(from: rootViewController,
to: toViewController, to: viewController,
duration: duration, duration: duration,
options: options, options: options,
animations: animations, animations: animations,
completion: { [weak self] (result: Bool) in completion: { [weak self] (result: Bool) in
if let s: RootController = self { guard let s = self else {
toViewController.didMove(toParentViewController: s) return
s.rootViewController.removeFromParentViewController() }
s.rootViewController = toViewController
s.rootViewController.view.clipsToBounds = true viewController.didMove(toParentViewController: s)
s.rootViewController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight] s.rootViewController.removeFromParentViewController()
s.rootViewController.view.contentScaleFactor = Device.scale s.rootViewController = viewController
completion?(result) s.rootViewController.view.clipsToBounds = true
} s.rootViewController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
s.rootViewController.view.contentScaleFactor = Device.scale
completion?(result)
}) })
} }
...@@ -163,21 +165,23 @@ open class RootController: UIViewController { ...@@ -163,21 +165,23 @@ open class RootController: UIViewController {
} }
/** /**
A method that adds the passed in controller as a child of A method that adds the passed in controller as a child of
the BarController within the passed in the BarController within the passed in
container view. container view.
- Parameter viewController: A UIViewController to add as a child. - Parameter viewController: A UIViewController to add as a child.
- Parameter container: A UIView that is the parent of the - Parameter container: A UIView that is the parent of the
passed in controller view within the view hierarchy. passed in controller view within the view hierarchy.
*/ */
internal func prepareControllerWithinContainer(viewController: UIViewController?, container: UIView) { internal func prepareControllerWithinContainer(viewController: UIViewController?, container: UIView) {
if let v: UIViewController = viewController { guard let v = viewController else {
addChildViewController(v) return
container.addSubview(v.view) }
v.didMove(toParentViewController: self)
v.view.clipsToBounds = true addChildViewController(v)
v.view.autoresizingMask = [.flexibleWidth, .flexibleHeight] container.addSubview(v.view)
v.view.contentScaleFactor = Device.scale v.didMove(toParentViewController: self)
} v.view.clipsToBounds = true
v.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
v.view.contentScaleFactor = Device.scale
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment