Skip to content

felix-dumit/FSDDropdownPicker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FSDDropdownPicker

Version License Platform

Example

Example

Usage

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

Create instance

You can create an intance directly by passing in an NSArray<id<FSDPickerItemProtocol>>* , if you just want an item with a name and image you can use the provided FSDPickerItem :

FSDPickerItem* item1 = [[FSDPickerItem alloc] initWithName:@"name" andImage:[UIImage imageNamed:@"1"]];
...    
FSDDropdownPicker *picker = [[FSDDropdownPicker alloc] initWithOptions:@[item1]];    

You will then have to add it to your view manually. You can alternatively use a convenience method to directly add the picker to the right or left of a navigation bar:

FSDDropdownPicker *picker =  [self.navigationItem addDropdownPickerWithOptions:@[item1, item2, item3] atPosition:FSDDropdownPickerNavigationPositionRight];

The dropdown picker will dismiss if you tap the dropdown button again, or if you tap outside the view and you have shouldHideOnOutsideTap turned on.

FSDDropdownPickerDelegate

The delegate can respond to the following events:

picker.delegate = self;

- (void)dropdownPicker:(FSDDropdownPicker *)dropdownPicker didDropDown:(BOOL)drop {
    //do something when the picker dropped down or up
}
- (BOOL)dropdownPicker:(FSDDropdownPicker *)dropdownPicker 	didSelectOption:(id <FSDPickerItemProtocol> )option {
	// called when user selects an option
}

Customization

You can customize the following options:

/**
 *  The height of each option in the dropdown picker
 */
@property (assign, nonatomic) CGFloat rowHeight;

/**
 *  Whether to show images when the picker drops down or not
 */
@property (assign, nonatomic) BOOL displaysImageInList;


/**
 *  The list separator style for the picker items
 */
@property (assign, nonatomic) UITableViewCellSeparatorStyle listSeparator;

/**
*  If the dropdown should hide when a tap outside (rest of window) happens. Default= YES
*/
@property (assign, nonatomic) BOOL shouldHideOnOutsideTap;

Installation

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

pod "FSDDropdownPicker"

Or to view the example project: pod try "FSDDropdownPicker"

Pull requests or any suggestions are welcome

Author

Felix Dumit, felix.dumit@gmail.com

License

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

About

A simple dropdown list picker for iOS

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published