Cameron E
Cameron E

Reputation: 1869

Expanding UIView from within UIToolbar?

I have a UeIView subclass as one of the UIToolbar's button items. When the user taps it, I would like it to expand out of the UIToolbar and display some options to the user. THe problem is, the UIToolbar is not letting the UIView present its subviews outside of the toolbar's frame. I have ClipToBounds set to NO everywhere, so that is not the problem.
Any suggestions on how to handle a situation like this?

Upvotes: 0

Views: 280

Answers (1)

Paras Joshi
Paras Joshi

Reputation: 20541

take one UIView with name viewOption after that set frame in viewDidLoad: method like bellow..

viewOption.frame = CGRectMake(0, yourToolBar.frame.origin.y, viewOption.frame.size.height, viewOption.frame.size.height);  /// define height and width which you want here

then in button event write this code and your view display with animation

-(IBAction)yourToolBarButton_Clicked:(id)sender
{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3];
     viewOption.frame = CGRectMake(0, 100, viewOption.frame.size.height, viewOption.frame.size.height);/// here set y as you want to display in view 
    [UIView commitAnimations];
}

Upvotes: 1

Related Questions