RMPZoomTransitionAnimator - 自定义缩放过渡动画的UIViewController

jopen 9年前

RMPZoomTransitionAnimator 提供了一个自定义缩放过渡动画。

不仅是UICollectionView, 这还能够使用其它任何UIViewController 过度。

This transition animation is like the "Pinterest" animation, but this is very simple and small library.

Screen shot Screen shot

Installation

RMPZoomTransitionAnimator is available through CocoaPods.
To install it, simply add the following line to your Podfile:

pod "RMPZoomTransitionAnimator"

Usage

To run the example project, clone the repo, and runpod installfrom the Example directory first.

Setup is as below:

Use for an UINavigationController push transition

Refer to the example project for details.

  • ImportRMPZoomTransitionAnimator.h
  • AdoptRMPZoomTransitionAnimating
  • Implement theRMPZoomTransitionAnimatingprotocol below, both source view controller and destination view controller
    1. - (UIImageView *)transitionSourceImageView
    2. - (UIColor *)transitionSourceBackgroundColor
    3. - (CGRect)transitionDestinationImageViewFrame
  • Returns RMPZoomTransitionAnimator instance in the UINavigationController delegate method
    - (id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController                                     animationControllerForOperation:(UINavigationControllerOperation)operation                                                  fromViewController:(UIViewController *)fromVC                                                    toViewController:(UIViewController *)toVC  {      // minimum implementation for example      RMPZoomTransitionAnimator *animator = [[RMPZoomTransitionAnimator alloc] init];      animator.goingForward = (operation == UINavigationControllerOperationPush);      animator.sourceTransition = (id<RMPZoomTransitionAnimating>)fromVC;      animator.destinationTransition = (id<RMPZoomTransitionAnimating>)toVC;      return animator;  }

Use for a modal transition

Refer to the example project for details.

  • ImportRMPZoomTransitionAnimator.h
  • AdoptRMPZoomTransitionAnimating
  • ImplementRMPZoomTransitionAnimatingprotocol below, both source view controller and destination view controller
    1. - (UIImageView *)transitionSourceImageView
    2. - (UIColor *)transitionSourceBackgroundColor
    3. - (CGRect)transitionDestinationImageViewFrame
  • Set the transitioningDelegate inprepareForSegue:sender:
  • Returns RMPZoomTransitionAnimator instance in the UIViewControllerTransitioningDelegate method
    - (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented                                                                    presentingController:(UIViewController *)presenting                                                                        sourceController:(UIViewController *)source  {      // minimum implementation for example      RMPZoomTransitionAnimator *animator = [[RMPZoomTransitionAnimator alloc] init];      animator.goingForward = YES;      animator.sourceTransition = (id<RMPZoomTransitionAnimating>)source;      animator.destinationTransition = (id<RMPZoomTransitionAnimating>)presented;      return animator;  }    - (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed  {      // minimum implementation for example      RMPZoomTransitionAnimator *animator = [[RMPZoomTransitionAnimator alloc] init];      animator.goingForward = NO;      animator.sourceTransition = (id<RMPZoomTransitionAnimating>)dismissed;      animator.destinationTransition = (id<RMPZoomTransitionAnimating>)self;      return animator;  }

Requirements

  • iOS 7.0 or higher

项目主页:http://www.open-open.com/lib/view/home/1428460097854