从UIToolbar中扩展UIView?

时间:2012-11-17 04:44:14

标签: iphone objective-c ios

我有一个UeIView子类作为UIToolbar's按钮项之一。当用户点击它时,我希望它扩展出UIToolbar并向用户显示一些选项。问题是,UIToolbar不允许UIViewsubviews框架之外显示其toolbar's。我ClipToBounds在任何地方都设置为NO,所以这不是问题 关于如何处理这种情况的任何建议?

1 个答案:

答案 0 :(得分:1)

UIView方法中设置框架之后,使用名称viewOption取viewDidLoad:viewOption.frame = CGRectMake(0, yourToolBar.frame.origin.y, viewOption.frame.size.height, viewOption.frame.size.height); /// define height and width which you want here

-(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];
}

然后在按钮事件中编写此代码并使用动画显示视图

{{1}}