Home

Awesome

#ARSSlideTransition

This library helps to achieve smooth custom view controller transition animation in your project. It uses your provided UIView objects to perform animations.

ARSSlideTransition

Installation

CocoaPods

To install with CocoaPods, copy and paste this in your Podfile file:

platform :ios, '7.0'
pod 'ARSSlideTransition', '~> 1.0'

Non-CocoaPods way

You can always to do the old way - just drag the source files into your projects and you are good to go.

Usage

Prepare your classes

In order to prepare your views for animation, you have to configure your UIViewControllers to support custom transition:

Presenting view controller
  1. Make sure, that in your view, that contains elements you wish to animate, you have set clipsToBounds property to NO. This will allow animate these elements outside of the view's bounds.

  2. Import ARSSlideTransition.h and conform to protocols UINavigationControllerDelegate and ARSSlideTransitionProtocol

@interface TableViewController () <UINavigationControllerDelegate, ARSSlideTransitionProtocol>
  1. Implement ARSSlideTransitionProtocol's required objectsToAnimate method. It should return NSArray of 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.

  2. Set your presenting viewController as a delegate for navigationController

self.navigationController.delegate = self;
  1. Implement UINavigationControllerDelegate method, 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;
}
Presented view controller
  1. Import ARSSlideTransition.h and conform to ARSSlideTransitionProtocol protocol.
  2. Implement ARSSlideTransitionProtocol's required method.

Customizing animation

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:

transition.pushAnimationDuration = 0.45; // Default.
transition.dismissAnimationDuration = 0.45; // Default
transition.springDamping = 0.8; // Default
transition.springVelocity = 0.8; // Default
transition.initialDelay = 0.0; // Default
transition.elementDelay = 0.05; // Default
transition.viewDelay = 0.15; // Default
transition.presentingViewAnimationOption = UIViewAnimationOptionCurveEaseOut; // Default
transition.presentedViewAnimationOption = UIViewAnimationOptionCurveEaseOut; // Default

License

ARSSlideTransition is released under the MIT license. See LICENSE for details.