Last active
January 12, 2016 03:49
-
-
Save onevcat/7f5391f3f8dcf5d73473 to your computer and use it in GitHub Desktop.
This file contains 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
public func tr_pushViewController<T where T: TRTransition, T.Content == UIViewController>(viewController: T, method: TRPushMethod, statusBarStyle: TRStatusBarStyle = .Default, completion: (() -> Void)? = nil) { | |
guard let vc = viewController as? T.Content else { | |
fatalError() | |
} | |
let transitionDelegate = TRNavgationTransitionDelegate(method: method, status: .Push, gestureFor: vc) | |
transitionDelegate.completion = completion | |
viewController.tr_transition = transitionDelegate | |
delegate = transitionDelegate | |
transitionDelegate.previousStatusBarStyle = TRStatusBarStyle.CurrentlyTRStatusBarStyle() | |
transitionDelegate.currentStatusBarStyle = statusBarStyle | |
pushViewController(vc, animated: true) | |
} |
This file contains 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
protocol TRTransition { | |
typealias Content = Self | |
} | |
extension UIViewController: TRTransition { | |
} | |
extension Int: TRTransition { | |
} | |
func miao<T where T: TRTransition, T.Content == UIViewController>(param: T) { | |
let p = param as! UIViewController | |
print(p.dynamicType) | |
} | |
miao(UIViewController()) // This is OK | |
miao(UITableViewController()) // This is also OK | |
miao(1) // Will not compile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment