Skip to content

Instantly share code, notes, and snippets.

@ltebean
Last active October 12, 2016 07:00
Show Gist options
  • Save ltebean/1b15535f3f1892dd76a5 to your computer and use it in GitHub Desktop.
Save ltebean/1b15535f3f1892dd76a5 to your computer and use it in GitHub Desktop.
animate window.rootViewController
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