GithubHelp home page GithubHelp logo

heke006 / icgtransitionanimation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from itsmeichigo/icgtransitionanimation

0.0 3.0 0.0 2.21 MB

ICGTransitionAnimation is a library to customize transition animation in iOS 7.

License: MIT License

Objective-C 98.38% Ruby 1.62%

icgtransitionanimation's Introduction

ICGTransitionAnimation

ICGTransitionAnimation is a library to customize transition animation in iOS 7.

Demo

Changes

v 1.02

  • Fix bug unable to show modal transition animation in storyboard.

v 1.01

  • Fix wrong animation transition direction.

v 1.0

  • First public release

Getting started

Using CocoaPods:

Just add the following line in to your pod file:

pod 'ICGTransitionAnimation', '~> 1.02'

Manually add ICGTransitionAnimation as a library:

Drag and drop the subfolder named ICGTransitionAnimation in your project and you are done.

Basic usage

  1. Custom navigation transition

Create an instance of ICGNavigationController and set your preferred animation controller with corresponding transition style (default style will be used if none is set).

    ICGNavigationController *navigationController = [[ICGNavigationController alloc] initWithRootViewController:viewController];
    ICGLayerAnimation *layerAnimation = [[ICGLayerAnimation alloc] initWithType:ICGLayerAnimationCover];
    navigationController.animationController = layerAnimation;

If you use storyboard, make sure your navigation controller's custom class is ICGNavigationController, just so you can set its animation controller via any of its view controller. For example, you can add this inside viewDidLoad method of your root view controller:

   ICGNavigationController *fancyNavigationController = (ICGNavigationController *)self.navigationController;
   ICGLayerAnimation *layerAnimation = [[ICGLayerAnimation alloc] initWithType:ICGLayerAnimationCover];
   fancyNavigationController.animationController = layerAnimation;

You can also take a look at the storyboard demo to find out how the library should be integrated.

  1. Custom modal transition

In order to customize the modal transition animation, you need to make sure your presenting view controller subclasses ICGViewController and set a custom animation controller to it.

One important note: The transition can only work if you set the modal view controller transitioning delegate to that of the presenting view controller (see the sample code below).

     // ICGMainViewController is a subclass of ICGViewController
   ICGMainViewController *mainController = [[ICGMainViewController alloc] initWithNibName:@"ICGFirstViewController" bundle:nil];
   ICGSlideAnimation *slideAnimation = [[ICGSlideAnimation alloc] init];
   slideAnimation.type = ICGSlideAnimationFromTop;
   mainController.animationController = slideAnimation;

   // View controller to be modally presented - this can subclass any UIViewController subclass.
   ICGModalViewController *modalController = [[ICGModalViewController alloc] initWithNibName:@"ICGModalViewController" bundle:nil];
   modalController.transitioningDelegate = mainController.transitioningDelegate; // this is important for the transition to work
   [modalController.navigationController presentViewController:viewController animated:YES completion:nil];
  1. Interactive transition

If you are using an animation controller that supports interactive transition, make sure to enable interaction on the object that you set the animation controller to.

   // If you want the push / pop transition to be interactive, enable interaction on your ICGNavigationController instance
   navigationController.interactionEnabled = YES;

   // If you want the modal transition to be interactive, enable interaction on the presenting view controller
   mainViewController.interactionEnabled = YES;

Advanced usage

By default, there are several available animation controllers provided in the library for basic transition customization. You are however encouraged to create your own, creative transition style by subclassing ICGBaseAnimation. The idea is pretty simple - you just need to override the mandatory method animateTransition: fromView: toView:. If you wish to add interactive transition too, be sure to override setInteractionEnabled.

For sample code, check out the implementation of ICGSlideAnimation provided in the library, which supports both custom animation and interaction transition.

Requirements

ICGTransitionAnimation requires Xcode 5 as it uses UIKit Dynamics and motion effects. The library supports iOS 7, but it's also compatible for iOS 6.

ARC

ICGTransitionAnimation uses ARC. If you are using ICGTransitionAnimation in a non-arc project, you will need to set a -fobjc-arc compiler flag on every ICGTransitionAnimation source files. To set a compiler flag in Xcode, go to your active target and select the "Build Phases" tab. Then select ICGTransitionAnimation source files, press Enter, insert -fobjc-arc and then "Done" to enable ARC for ICGTransitionAnimation.

Contributing

Contributions for bug fixing or improvements are welcomed. Feel free to submit a pull request.

Licence

ICGTransitionAnimation is available under the MIT license. See the LICENSE file for more info.

icgtransitionanimation's People

Watchers

He Ke avatar James Cloos avatar He Hai avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.