Giter Site home page Giter Site logo

bhaveshdhaduk / adfliptransition Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adamdebono/adfliptransition

0.0 2.0 0.0 285 KB

An alternative presentation animation for iOS. Mimics the flip animation from the iOS iTunes/App Store.

License: Other

adfliptransition's Introduction

ADFlipTransition

An easy to use presentation animation. Transition from one view controller to another. Can be performed modally or as a at a specific frame. Easily add a transition from a cell in a UICollectionViewController or UITableViewController. There are also categories which provide convenience methods for one-line calls, just as you would present any other modal view controller.

Note that modal presentation currently only supports full screen presentation.

Requirements

  • Objective-C ARC
  • Xcode 4.4 or above
  • iOS 5 or above

Installation

Once you have got the source, you can install the component in two ways.

As a dependency

  1. Drag the ADFlipTransition.xcodeproj file into your xcode project. Make sure that it is not open in another window
  2. Click on the project settings and navigate to the target you wish to install for. Click build phases. Add ADFlipTransition to your 'Target Dependencies'.
  3. Add the following to 'Link Binary With Libraries': (If not already)
    • libADFlipTransition
    • QuartzCore
  4. Go to the 'Build Setting' tab. Add '-ObjC' and '-all_load' to 'Other Linker Flags'
  5. Add the repository's file directory to 'User Header Search Paths'

Import the files

  1. Drag ADFlipTransition.h & .m and UIView+Snapshot.h & .m into your project, and any of the view controller categories you wish to use.
  2. Add QuartzCore to 'Link Binary With Libraries' in your target's 'Build Phases' (If not already)
  3. If you're not using ARC, add -f-objc-arc to ADFlipTransition.m's compiler flags. (In 'Build Phases' -> 'Compile Sources')

Using ADFlipTransition

One Line Presentation

#import "UIViewController+ADFlipTransition.h"

@implementation MyViewController 

- (IBAction)showFlippedViewButtonPressed:(UIButton *)sender {
	FlippedViewController *flippedViewController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"flippedViewController"];
	[self flipToViewController:flippedViewController fromView:sender withCompletion:NULL];
}

@end

Then to dismiss it:

#import UIViewController+ADFlipTransition.h

@implementation FlippedViewController

- (IBAction)backPressed:(UIButton *)sender {
	[self dismissFlipWithCompletion:NULL];
}

@end

From a UICollectionViewController

(Or a UITableViewController โ€“ just swap 'collection' for 'table')

If the index path used refers to a cell which is off-screen, the cell will be scrolled into place (not animated).

#import "UICollectionViewController+ADFlipTransition.h"

@implementation MyCollectionViewController 

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
	FlippedViewController *flippedViewController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"flippedViewController"];
	[self flipToViewController:flippedViewController fromItemAtIndexPath:indexPath withCompletion:NULL];
}

@end

Dismiss back to a collection/table view controller the same as normal, or you can update the index path if needed.

#import UIViewController+ADFlipTransition.h

@interface FlippedViewController ()

@property (strong, nonatomic) NSInteger pageNumber;

@end

@implementation FlippedViewController

- (IBAction)backPressed:(UIButton *)sender {
	[self dismissFlipToIndexPath:[NSIndexPath indexPathForRow:[self pageNumber] inSection:0] withCompletion:NULL];
}

@end

For more sample code, check out the demo, included with the repository

License

The MIT License (MIT)

Copyright (c) 2013 Adam Debono

This software is provided under the terms of the MIT License (MIT), as provided below. I would greatly appreciate commendation within a 'credits' or 'licenses' section where this is used.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

adfliptransition's People

Contributors

dmauer avatar

Watchers

 avatar  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.