In some areas of my UI I wanted more control over the animations in my navigation stack. This thread on Stack Overflow was a great place to start. I ported some of the Objective-C code I found to C# extension methods as follows:
//Allows a UINavigationController to push using a custom animation transition
public static void PushControllerWithTransition(this UINavigationController
target, UIViewController controllerToPush,
UIViewAnimationOptions transition)
{
UIView.Transition(target.View, 0.75d, transition, delegate() {
target.PushViewController(controllerToPush, false);
}, null);
}
//Allows a UINavigationController to pop a using a custom animation
public static void PopControllerWithTransition(this UINavigationController
target, UIViewAnimationOptions transition)
{
UIView.Transition(target.View, 0.75d, transition, delegate() {
target.PopViewControllerAnimated(false);
}, null);
}With these extensions in scope, moving between controllers with a flip animation is now as trivial as this://Pushing someController to the top of the stack NavigationController.PushControllerWithTransition(someController, UIViewAnimationOptions.TransitionFlipFromLeft); //Popping the current controller off the top of the stack NavigationController.PopControllerWithTransition( UIViewAnimationOptions.TransitionFlipFromRight);
2 comments:
Perfect. Thank you.
Perfect. Thank you.
Post a Comment