#ARSSlideTransition
This library helps to achieve smooth custom view controller transition animation in your project. It uses your provided UIView objects to perform animations.
To install with CocoaPods, copy and paste this in your Podfile file:
platform :ios, '7.0'
pod 'ARSSlideTransition', '~> 1.0'
You can always to do the old way - just drag the source files into your projects and you are good to go.
In order to prepare your views for animation, you have to configure your UIViewControllers to support custom transition:
-
Make sure, that in your view, that contains elements you wish to animate, you have set
clipsToBoundsproperty toNO. This will allow animate these elements outside of the view's bounds. -
Import
ARSSlideTransition.hand conform to protocolsUINavigationControllerDelegateandARSSlideTransitionProtocol
@interface TableViewController () <UINavigationControllerDelegate, ARSSlideTransitionProtocol>-
Implement
ARSSlideTransitionProtocol's requiredobjectsToAnimatemethod. It should returnNSArrayof UIView class/subclass objects, that you wish to animate. Order matters - objects are going to be animated in the same order as they are presented in array. -
Set your presenting viewController as a delegate for navigationController
self.navigationController.delegate = self;- Implement
UINavigationControllerDelegatemethod, to let iOS know, that custom transition would be used instead of the default one:
(id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC
{
ARSSlideTransition *transition = [ARSSlideTransition new];
transition.operation = operation;
return transition;
}- Import
ARSSlideTransition.hand conform toARSSlideTransitionProtocolprotocol. - Implement
ARSSlideTransitionProtocol's required method.
In case you specify only those three lines of code from step 4 in the section above, then default animation parameters are going to be used.
In order to provide your custom tweaks or configurations to animation's behavior, you are able to use these properties:
pushAnimationDuration- specify presenting view controller's animation duration.
transition.pushAnimationDuration = 0.45; // Default.dismissAnimationDuration- specify presented view controller's animation duration.
transition.dismissAnimationDuration = 0.45; // DefaultspringDamping- specify spring damping ratio for spring animation.
transition.springDamping = 0.8; // DefaultspringVelocity- specify spring velocity ratio for spring animation.
transition.springVelocity = 0.8; // DefaultinitialDelay- specify initial delay, after which animation transition will be launched.
transition.initialDelay = 0.0; // DefaultelementDelay- specify delay for animating each following view element.
transition.elementDelay = 0.05; // DefaultviewDelay- specify delay for animating presented view controller's elements.
transition.viewDelay = 0.15; // DefaultpresentingViewAnimationOption- specify animation option for presenting view.
transition.presentingViewAnimationOption = UIViewAnimationOptionCurveEaseOut; // DefaultpresentedViewAnimationOption- specify animation option for presented view.
transition.presentedViewAnimationOption = UIViewAnimationOptionCurveEaseOut; // DefaultARSSlideTransition is released under the MIT license. See LICENSE for details.
