Coder Social home page Coder Social logo

kartel / jtmaterialtransition Goto Github PK

View Code? Open in Web Editor NEW

This project forked from johnvuko/jtmaterialtransition

0.0 2.0 0.0 426 KB

An iOS transition for controllers based on material design.

License: MIT License

Objective-C 67.05% Ruby 8.51% C 2.89% Shell 21.55%

jtmaterialtransition's Introduction

JTMaterialTransition

CI Status Version License Platform

An iOS transition for controllers based on material design.

Installation

With CocoaPods, add this line to your Podfile.

pod 'JTMaterialTransition', '~> 1.0'

Screenshots

Example

Usage

Basic usage

#import <UIKit/UIKit.h>

// You have to implement UIViewControllerTransitioningDelegate protocol
@interface ViewController : UIViewController<UIViewControllerTransitioningDelegate>
@end
#import "ViewController.h"

#import <JTMaterialTransition.h>
#import "SecondViewController.h"

@implementation ViewController

@interface ViewController ()

@property (nonatomic) JTMaterialTransition *transition;
@property (nonatomic) UIButton *presentControllerButton;

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    // No specific moment to call this method, just before presenting a controller
    [self createTransition];
}

- (void)didPresentControllerButtonTouch
{
    // The controller you want to present
    UIViewController *controller = [SecondViewController new];
    
    // Indicate you use a custom transition
    controller.modalPresentationStyle = UIModalPresentationCustom;
    controller.transitioningDelegate = self;

    [self presentViewController:controller animated:YES completion:nil];
}

// Initialize the tansition
- (void)createTransition
{
    // self.presentControllerButton is the animatedView used for the transition
    self.transition = [[JTMaterialTransition alloc] initWithAnimatedView:self.presentControllerButton];
}

// Indicate which transition to use when you this controller present a controller
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented
                                                                  presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source
{
    self.transition.reverse = NO;
    return self.transition;
}

// Indicate which transition to use when the presented controller is dismissed
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
{
    self.transition.reverse = YES;
    return self.transition;
}
@end

Notes

The animatedView is not directly used, a new view is created based on the frame, backgroundColor properties for the animation. If you don't want to provide a view, you have to set startFrame and startBackgroundColor properties and call init instead of initWithAnimatedView:. startFrame must be the coordinates relative to the window.

Requirements

  • iOS 7 or higher
  • Automatic Reference Counting (ARC)

Author

License

JTMaterialTransition is released under the MIT license. See the LICENSE file for more info.

jtmaterialtransition's People

Contributors

johnvuko avatar

Watchers

James Cloos avatar Neil García 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.