Dropdown Menu for iOS with many customizable parameters to suit any needs.
Inspired by UIPickerView.
MKDropdownMenu is available through CocoaPods. To install it, simply add the following line to your Podfile:
MKDropdownMenufolder to your Xcode project.
#import "MKDropdownMenu.h"in your code.
See the example Xcode project.
MKDropdownMenu instance and add it as a subview to your view. Set the
delegate properties to your view controller implementing
MKDropdownMenu *dropdownMenu = [[MKDropdownMenu alloc] initWithFrame:CGRectMake(0, 0, 320, 44)]; dropdownMenu.dataSource = self; dropdownMenu.delegate = self; [self.view addSubview:dropdownMenu];
You can also set up the
MKDropdownMenu in Interface Builder.
- Add a
UIViewand set its class to
MKDropdownMenuin the Identity inspector.
- Connect the
delegateoutlets to your view controller.
Populating the data
MKDropdownMenuDelegate protocols APIs are inspired by the
UIPickerView interface, so most of the methods should be familiar if you used it before.
Implement the following
- (NSInteger)numberOfComponentsInDropdownMenu:(MKDropdownMenu *)dropdownMenu; - (NSInteger)dropdownMenu:(MKDropdownMenu *)dropdownMenu numberOfRowsInComponent:(NSInteger)component;
delegate methods that suit your needs. The most simple way to get started is to provide the titles for the header components and the rows in the following
- (NSString *)dropdownMenu:(MKDropdownMenu *)dropdownMenu titleForComponent:(NSInteger)component; - (NSString *)dropdownMenu:(MKDropdownMenu *)dropdownMenu titleForRow:(NSInteger)row forComponent:(NSInteger)component;
You can also provide an
NSAttributedString or custom
UIView as the display data for
MKDropdownMenu in the corresponding
The appearance and behavior of the
MKDropdownMenu can be customized by setting its property values or implementing the corresponding
The default menu appearance can be customized throughout the app using the available
- iOS 8+
- Xcode 8+
MKDropdownMenu is available under the MIT license. See the LICENSE file for more info.