Git Product home page Git Product logo

vsdropdown's Introduction

VSDropdown Build Status

Dropdown for iOS

VSDropdown is an iOS drop-in class which can be used to show menu item below/above UIButton. This class adapts appearance of the button for which it is shown, which you can customise, and presents itself with appropriate frame and direction. Irrespective of the button's hierarchy in the Window, the Dropdown takes touches everywhere on the screen. It dismisses itself when tapped outside its bounds.

Usage

[_dropdown setupDropdownForView:_myButton];

[_dropdown reloadDropdownWithContents:@[@"Hello World",@"Dropdown test",@"Bla Bla bla.."] andSelectedItems:@[_myButton.titleLabel.text]];

If you have an Array containing custom modal classes, for eg. countries array containing Country objects. You want to show value of name property of all Country objects in dropdown list , you can use below method. name should be of NSString type.

[_dropdown reloadDropdownWithContents:self.countries keyPath:@"name" selectedItems:@[_myButton.titleLabel.text]];

##Other adoptParentTheme property can be used when the button has solid background color. When this is YES, the dropdown draws itslef with a gradient color which matches with the button's background color.

You can tweak the componets of background color using below functions:

-(void)setupDropdownForView:(UIView *)view direction:(Dropdown_Direction)direction withBaseColor:(UIColor *)baseColor scale:(float)scale;
   
-(void)setupDropdownForView:(UIView *)view direction:(Dropdown_Direction)direction withTopColor:(UIColor *)topColor bottomColor:(UIColor *)bottomColor scale:(float)scale;

About Sample

In the sample, there are buttons of different background colors, sizes and fonts. Note that only one VSDropdown instance is used for all the button. Whenever a setupDropDownForView: message is called on VSDropdown instance, it removes itslef from its previous superview, if any, and draws itslef again for the UIButton passed in the argument.

UPDATE : Animation type has been added and in the sample project, dropdwon takes random values from available DropdownAnimation types.

How it looks?

Alt text

Individual screen shots [here] (Screenshots).

License

This code is distributed under the terms and conditions of the MIT license.

vsdropdown's People

Contributors

vishal-singh-panwar avatar swiftales avatar

Watchers

James Cloos 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.