GithubHelp home page GithubHelp logo

xhacker / lgsemimodalnavcontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lukegeiger/lgsemimodalnavcontroller

0.0 3.0 0.0 809 KB

A UINavigationController subclass that presents itself a dynamic amount in a view controller using the UIViewControllerAnimatedTransitioning protocol.

License: MIT License

Objective-C 53.00% Ruby 4.64% C 3.40% Shell 38.96%

lgsemimodalnavcontroller's Introduction

LGSemiModalNavController

Version License Platform

Purpose & Description

The purpose of the LGSemiModalNavController is to allow you to show a view controller a dynamically set height over another view controller.

The effect this custom transition gives off is that a view partially springs up from the bottom of the screen and into place. The view that gets sprung over, gets scaled down by a customizable amount.

Under The Hood

There are two classes that play together to make this happen. the LGSemiModalNavViewController and the LGSemiModalTransition. The LGSemiModalNavViewController subscribes to the UIViewControllerTransitioningDelegate. The LGSemiModalTransition subscribes to UIViewControllerAnimatedTransitioning.

// LGSemiModalNavViewController.m

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented
                                                                  presentingController:(UIViewController *)presenting
                                                                      sourceController:(UIViewController *)source {
    return [self transitionPresenting:YES];
}

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
    return [self transitionPresenting:NO];
}

-(LGSemiModalTransition*)transitionPresenting:(BOOL)presenting{
    LGSemiModalTransition *animator = [LGSemiModalTransition new];
    animator.presenting = presenting;
    animator.tapDismissEnabled = _tapDismissEnabled;
    animator.animationSpeed = _animationSpeed;
    animator.backgroundShadeColor = _backgroundShadeColor;
    animator.scaleTransform = _scaleTransform;
    animator.springDamping = _springDamping;
    animator.springVelocity = _springVelocity;
    animator.backgroundShadeAlpha = _backgroundShadeAlpha;
    return animator;
}

Example

    //This is an example.
    LGViewController *lgVC = [[LGViewController alloc]initWithFormat:LGViewControllerFormatGoBack];
    
    //This is the nav controller
    LGSemiModalNavViewController *semiModal = [[LGSemiModalNavViewController alloc]initWithRootViewController:lgVC];
    //Make sure to set a height on the view controller here.
    semiModal.view.frame = CGRectMake(0, 0, self.view.frame.size.width, 400);
    
    //Selected customization properties, see more in the header of the LGSemiModalNavViewController
    semiModal.backgroundShadeColor = [UIColor blackColor];
    semiModal.animationSpeed = 0.35f;
    semiModal.tapDismissEnabled = YES;
    semiModal.backgroundShadeAlpha = 0.4;
    semiModal.scaleTransform = CGAffineTransformMakeScale(.94, .94);
    
    [self presentViewController:semiModal animated:YES completion:nil];

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

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

pod "LGSemiModalNavController"

Authors

Special thanks to Mathew Piccinato who helped develop this with me!

Luke Geiger, @lukejgeiger

Mathew Piccinato, @mpiccinato

License

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

lgsemimodalnavcontroller's People

Contributors

lukegeiger avatar

Watchers

James Cloos avatar 柳东原 · Dongyuan Liu 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.