Last active
October 12, 2016 07:00
-
-
Save ltebean/1b15535f3f1892dd76a5 to your computer and use it in GitHub Desktop.
animate window.rootViewController
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
class AppCoordinator: NSObject { | |
var window: UIWindow! | |
static let shared = AppCoordinator() | |
func goToHome() { | |
let target = R.storyboard.home.home()! | |
animateTo(vc: target) | |
} | |
func goToSignup() { | |
let target = R.storyboard.account.signup()! | |
animateTo(vc: target) | |
} | |
private func animateTo(vc: UIViewController) { | |
let current = window.rootViewController! | |
let options: UIViewAnimationOptions = [.transitionFlipFromLeft, .curveEaseInOut] | |
UIView.transition(from: current.view, to: vc.view, duration: 1, options: options) { finished in | |
self.window.rootViewController = vc | |
} | |
} | |
func showFirstScreen() { | |
// TODO check whether user has logged in | |
if true { | |
window.rootViewController = R.storyboard.account.signup()! | |
} else { | |
window.rootViewController = R.storyboard.home.home()! | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment