Skip to content

soberman/ARSSlideTransition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#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:

  • 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; // Default
  • springDamping - specify spring damping ratio for spring animation.
transition.springDamping = 0.8; // Default
  • springVelocity - specify spring velocity ratio for spring animation.
transition.springVelocity = 0.8; // Default
  • initialDelay - specify initial delay, after which animation transition will be launched.
transition.initialDelay = 0.0; // Default
  • elementDelay - specify delay for animating each following view element.
transition.elementDelay = 0.05; // Default
  • viewDelay - specify delay for animating presented view controller's elements.
transition.viewDelay = 0.15; // Default
  • presentingViewAnimationOption - specify animation option for presenting view.
transition.presentingViewAnimationOption = UIViewAnimationOptionCurveEaseOut; // Default
  • presentedViewAnimationOption - specify animation option for presented view.
transition.presentedViewAnimationOption = UIViewAnimationOptionCurveEaseOut; // Default

License

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

About

Custom slide view controller transition animation.

Resources

License

Stars

Watchers

Forks

Packages

No packages published