I got an app with NavigationController
. How can i change animation transition style of pushViewController
and popToViewController
?
UPD
I created category like in @lawicko answer. But i got error when i am trying to call function
[self.navigationController pushViewController:places withCustomTransition:CustomViewAnimationTransitionPush subtype:CustomViewAnimationSubtypeFromLeft];
error is : "use of undeclared identifier 'CustomViewAnimationTransitionPush'"
Where should i declare this part:
typedef enum {
CustomViewAnimationTransitionNone,
CustomViewAnimationTransitionFlipFromLeft,
CustomViewAnimationTransitionFlipFromRight,
CustomViewAnimationTransitionCurlUp,
CustomViewAnimationTransitionCurlDown,
CustomViewAnimationTransitionFadeIn,
CustomViewAnimationTransitionMoveIn,
CustomViewAnimationTransitionPush,
CustomViewAnimationTransitionReveal
} CustomViewAnimationTransition;
Write now i declare it in UINavigationController+Additions.h
UPD 2: One more new error:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_CATransition", referenced from:
objc-class-ref in UINavigationController+Additions.o
"_kCATransition", referenced from:
and same errors foor all _kCATransitions
Check out this
UINavigationController
category that I created. It allows you pushing and popping with pretty much every possible transition, and also supports subtypes for QuartzCore transitions, which will allow you to do exactly what you want - push the view from the left. Do it like this:The code is below. The first part you need to put in the header part:
This second part you need to put in the implementation file:
I recently tackled creating my own transition, here's the reusable library I made:
https://github.com/travisjeffery/TRVSNavigationControllerTransition
And here's my blog post talking about how to make your own transition.
The basic idea is pretty simple though, just take a CALayer snapshot of the navigationController's (current) view, then push/pop the view off without animation, take a CALayer snapshot of the new view and then add your own animations to those layers and then remove those layers once the animation is completed.
You need to add
QuartzCore.framework
to your target to solve_OBJC_CLASS_$_CATransition
error.