Giter Site home page Giter Site logo

nicejinux / guillotinemenu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yalantis/guillotinemenu

0.0 1.0 0.0 454 KB

Our Guillotine Menu Transitioning Animation implemented in Swift reminds a bit of a notorious killing machine.

Home Page: https://yalantis.com/

License: MIT License

Ruby 3.08% Swift 96.92%

guillotinemenu's Introduction

GuillotineMenu.swift

CocoaPods Compatible Swift 2.2.x

Preview

Inspired by this project on Dribbble

Also, read how it was done in our blog

Requirements

iOS 8.0

Installation

####CocoaPods

pod 'GuillotineMenu', '~> 2.0.2'

####Manual Installation

You are welcome to see the sample of the project for fully operating sample in the Example folder.

  • You must add "GuillotineMenuTransitionAnimation.swift" to your project, that's all.

Usage

  • Now, it's for you to decide, should or not your menu drop from top left corner of the screen or from your navigation bar, because if you want animation like in example, you must make your menu view controller confirm to "GuillotineMenu" protocol. When you confirm to this protocol, you must make a menu button and title, you don't need to make frame for them, because animator will make it itself.
  • In view controller, that will present your menu, you must make a property for "GuillotineMenuTransitionAnimator". It's necessary for proper animation when you show or dismiss menu.
  • When you present menu, you must ensure, that model presentation style set to Custom and menu's transition delegate set to view controller, that presents menu:
let menuViewController = storyboard!.instantiateViewControllerWithIdentifier("MenuViewController")
menuViewController.modalPresentationStyle = .Custom
menuViewController.transitioningDelegate = self
  • Implement UIViewControllerTransitionDelegate methods in your presenting view controller:
extension ViewController: UIViewControllerTransitioningDelegate {

func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
presentationAnimator.mode = .Presentation
return presentationAnimator
}

func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
presentationAnimator.mode = .Dismissal
return presentationAnimator
}
}
  • At last, you can assign offset view, from where your menu will be dropped and button for it, and present your menu:
presentationAnimator.supportView = self.navigationController?.navigationBar
presentationAnimator.presentButton = sender
self.presentViewController(menuVC, animated: true, completion: nil)

Customisation

Of course, you can assign different "supportView" or "presentButton" for menu, but we think that's the best case would be behaviour like in Example project.

To specify the length of an animation effect, change the value of the "duration" property.

Also, you have wonderful delegate methods of animator:

protocol GuillotineAnimationDelegate: NSObjectProtocol {

optional func animatorDidFinishPresentation(animator: GuillotineTransitionAnimation)
optional func animatorDidFinishDismissal(animator: GuillotineTransitionAnimation)
optional func animatorWillStartPresentation(animator: GuillotineTransitionAnimation)
optional func animatorWillStartDismissal(animator: GuillotineTransitionAnimation)
}

You can do whatever you want alongside menu is animating.

Compatibility

iOS 8, 9

Version: 2.0.1

Let us know!

We’d be really happy if you sent us links to your projects where you use our component. Just send an email to [email protected] And do let us know if you have any questions or suggestion regarding the animation.

P.S. We’re going to publish more awesomeness wrapped in code and a tutorial on how to make UI for iOS (Android) better than better. Stay tuned!

License

The MIT License (MIT)

Copyright (c) 2016 Yalantis

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.

guillotinemenu's People

Contributors

edbaev avatar egorsobko avatar joekr avatar makstheawesome avatar maximletushov avatar mrcompoteee avatar serejahh avatar

Watchers

 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.