Iphone Dev - Drop down list of Buttons when button pressed
I need to implement a button (let's say with a picture of arrow down before pressed), that when pressed, will open a drop down list other button I'll set dynamically. The drop needs to show one button at a time, using some kind of animation.
Is there a preferred way of doing it. (ne开发者_运维技巧ver worked with animation before) Similar source code would be of great help.
Thanks
I did something similar where I had a table view with a navigation bar. The bar had a button to show/hide filters, which would animate down from the top. The code I used was:
CGFloat filterViewHeight = kExtendedFilterViewHeight;
if(![self includeSecondaryFilter])
filterViewHeight = kDefaultFilterViewHeight;
if(!allButton.selected && [self includeSecondaryFilter])
filterViewHeight -= kSecondaryFilterHeight;
filtersView.frame = CGRectMake(0.0, -filterViewHeight, 320.0, filterViewHeight);
[self.view addSubview:filtersView];
CGRect tableViewFrame = itemTableView.frame;
CGRect filtersViewFrame = filtersView.frame;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
[UIView setAnimationDelegate:self];
tableViewFrame.origin.y = filterViewHeight;
tableViewFrame.size.height -= filterViewHeight;
itemTableView.frame = tableViewFrame;
filtersViewFrame.origin.y = 0.0;
filtersView.frame = filtersViewFrame;
[UIView commitAnimations];
Hope this helps!
精彩评论