A Tweetbot 3-like drop down menu made from the UIToolbar class (like the tweetbot list view by holding down the title)
Tweetbot : CABarMenu : Video Demo
CABarMenu's content supports any kind of subview class! In the example, I use a table view. Images, collection views, buttons, and text fields also work fine.
- Simply import all files from the
Classes
folder in to your project. - In your desired view, import CABarMenu.h
- Define a CABarMenu in your implementation.
CABarMenu *menu;
- In [super viewDidLoad], call
menu = [[CABarMenu alloc] init];
- Make a button or something that shows/hides the menu. To show the menu,
you can use:
[menu showFromNavigationBar:navbarnamehere animated:YES];
And to hide the menu,[menu hideAnimated:YES];
.
You can customise the appearance of the bar in CABarMenu.m by adjusting the defaults in the 'init' method.
To add the table view like in the demo, you can use this snippet:
UITableView *tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 40, 0, 416)];
tableview.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
tableview.delegate = self;
tableview.dataSource = self;
tableview.backgroundColor = [UIColor clearColor];
tableview.scrollIndicatorInsets = UIEdgeInsetsZero;
tableview.contentInset = UIEdgeInsetsZero;
[tableview setSeparatorInset:UIEdgeInsetsZero];
[menu addSubview:tableview];
Since this is from the UIToolBar class, it responds to barTint, backgroundColor, and many other methods.
Feel free to submit pull requests!
-Colton