如何将下拉菜单添加到iOS中的导航栏标题
我想在这些屏幕截图中制作类似于下拉菜单的内容。我该怎么做?
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.
您的应用中有很多cocoacontrol可以执行此功能:
There are lots of cocoacontrols to perform this function in your app:
但是我认为 lmdropdownview 是最准确的。
But I think lmdropdownview is the most accurate.
我的错误, btnavigationdropdownmenu 对你要问的内容最准确(根据你的屏幕) )。
My mistake, btnavigationdropdownmenu ITS the most accurate for what you are asking (according to your screens).
实施(Swift)[有关更多特殊说明和定制,请参阅自述文件]:
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]
}
希望有所帮助。
编辑:
感谢'rsc'获取信息, objective-c version 这个cocoacontrol:
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;
}