2014-04-12 174 views
-3

有谁知道我可以如何点击按钮并从顶部显示面板?从顶部滑动视图

与点击搜索按钮后YouTube应用显示搜索栏的方式类似。

不确定如何从顶部滑动视图并在视图上显示。

任何想法?

+0

您需要提供更多信息。你想让菜单滑下来?如果它有一个手势,我个人会避免使用这种类型的用户界面,因为苹果的通知中心从顶部滑下来 - 所以这可能会与您的设计相冲突。 – Tander

回答

0

有没有这样的事情,似乎工作,但并不顺利,因为我希望第一次发射后点几下开始工作

if (showBanner == false) { 

    showBanner = true; 
    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDuration:0.5]; 
    [UIView setAnimationDelay:0.0]; 
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; 

    [UIButton beginAnimations:nil context:nil]; 
    [UIButton setAnimationDuration:0.5]; 
    [UIButton setAnimationDelay:0.0]; 
    [UIButton setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

    scrollView.frame = CGRectMake(0, 0, 320, 100); 
    openMenu.frame = CGRectMake(267,101, 47, 30); 

    [self.view bringSubviewToFront:scrollView]; 
    [UIView commitAnimations]; 

} 
else{ 

    showBanner = false; 
    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDuration:0.5]; 
    [UIView setAnimationDelay:0.0]; 
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

    [UIButton beginAnimations:nil context:nil]; 
    [UIButton setAnimationDuration:0.5]; 
    [UIButton setAnimationDelay:0.0]; 
    [UIButton setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

    scrollView.frame = CGRectMake(0, -100, 320, 100); 
    openMenu.frame = CGRectMake(262, 20, 47, 30); 

    [UIView commitAnimations]; 

} 

任何想法,为什么这不适合工作第一次点击几次?

+0

通过添加滚动视图来查看确实加载解决 – tau

0

在您的视图中,负载将滑动视图的原始y值设置为负值(使其刚好离开屏幕顶部)。

然后,当您希望它出现时将y值设置为0,您可以使用UIView:animateWithDuration进行动画。

它的一个出现,如果你想你可以添加一个平移手势识别器,以便用户可以刷回备份,或者你可以触发它以编程方式恢复。