I want to make something similar to the dropdown menu in these screenshots. How would I go about doing that?
When you tap the title, the arrow points up and a menu drops down. The App Is College Menus.
Use any element to open the dropdown menu, e.g. a <button>, <a> or <p> element. Use a container element (like <div>) to create the dropdown menu and add the dropdown links inside it. Wrap a <div> element around the button and the <div> to position the dropdown menu correctly with CSS.
A drop-down menu is a clean method of showing a large list of choices since only one choice is displayed initially until the user activates the drop-down box. To add a drop-down menu to a web page, you would use a <select> element.
There are lots of cocoacontrols to perform this function in your app:
DropDown Menu Controls For iOS
But I think lmdropdownview is the most accurate.
My mistake, btnavigationdropdownmenu ITS the most accurate for what you are asking (according to your screens).
Implementation (Swift)[See the readme for more speceific instructions, and customization]:
let items = ["Most Popular", "Latest", "Trending", "Nearest", "Top Picks"]
let menuView = BTNavigationDropdownMenu(frame: CGRectMake(0.0, 0.0, 300, 44), title: items.first!, items: items, containerView: self.view)
self.navigationItem.titleView = menuView
menuView.didSelectItemAtIndexHandler = {(indexPath: Int) -> () in
println("Did select item at index: \(indexPath)")
self.selectedCellLabel.text = items[indexPath]
}
Hope it helps.
EDIT:
Thanks for 'rsc' for the info, theres an objective-c version of this cocoacontrol:
#import "PFNavigationDropdownMenu.h"
-(void)viewDidLoad{
PFNavigationDropdownMenu *menuView = [[PFNavigationDropdownMenu alloc]initWithFrame:CGRectMake(0, 0, 300, 44)title:items.firstObjects items:items containerView:self.view];
menuView.didSelectItemAtIndexHandler = ^(NSUInteger indexPath){
NSLog(@"Did select item at index: %ld", indexPath);
self.selectedCellLabel.text = items[indexPath];
};
self.navigationItem.titleView = menuView;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With