GithubHelp home page GithubHelp logo

hpique / vertigo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gonzalezreal/vertigo

0.0 2.0 1.0 1.39 MB

Simple full screen image viewer with image zoom custom view controller transition

License: Other

vertigo's Introduction

Vertigo

Vertigo is a simple image viewer which includes a custom view controller transition that mimics the new iOS 7 Photos app image zoom transition effect.

Image zoom transition

Installation

Requirements

Vertigo requires iOS 7 or greater.

From CocoaPods

Add pod 'Vertigo' to your Podfile.

Manually

Drag the Vertigo folder into your project. If your project doesn't use ARC you must enable it for all the .m files under the Vertigo folder.

Usage

Vertigo includes the following classes:

  • TGRImageViewController is the image viewer itself. The user can double tap on the image to zoom it in or out. A single tap will dismiss the viewer.
  • TGRImageZoomAnimationController is the object that performs the custom transition between your view controller and a TGRImageViewController (that is, the Photos app image zoom transition effect).

To present and dismiss a TGRImageViewController from your view controller using the custom transition effect, your view controller needs to implement the new UIViewControllerTransitioningDelegate protocol and return a TGRImageZoomAnimationController initialized with the image view that will be used as the inital (or final in case of dismissal) point of the transition.

#import "TGRImageViewController.h"
#import "TGRImageZoomAnimationController.h"

@interface MyViewController () <UIViewControllerTransitioningDelegate>
@end

@implementation MyViewController
...
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
    if ([presented isKindOfClass:TGRImageViewController.class]) {
        return [[TGRImageZoomAnimationController alloc] initWithReferenceImageView:self.imageView];
    }
    return nil;
}

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
    if ([dismissed isKindOfClass:TGRImageViewController.class]) {
        return [[TGRImageZoomAnimationController alloc] initWithReferenceImageView:self.imageView];
    }
    return nil;
}

- (IBAction)showImageViewer {
    TGRImageViewController *viewController = [[TGRImageViewController alloc] initWithImage:self.imageView.image];
    // Don't forget to set ourselves as the transition delegate
    viewController.transitioningDelegate = self;
    
    [self presentViewController:viewController animated:YES completion:nil];
}

Contact

Guillermo Gonzalez
@gonzalezreal

License

Vertigo is available under the MIT license. See LICENSE.

vertigo's People

Contributors

brianeunilkim avatar gonzalezreal avatar

Watchers

 avatar  avatar

Forkers

alexguoq

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.