解决方法
在您的应用程序中执行此功能有很多cocoacontrols:
DropDown Menu Controls For iOS
但我认为lmdropdownview是最准确的.
我的错误,btnavigationdropdownmenu ITS是最准确的你所要求的(根据你的屏幕).
实施(Swift)[更多详细说明和定制请参阅自述文件]:
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这个可可控制:
#import "PFNavigationDropdownMenu.h" -(void)viewDidLoad{ PFNavigationDropdownMenu *menuView = [[PFNavigationDropdownMenu alloc]initWithFrame:CGRectMake(0,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; }