2014-04-12 167 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進行動畫。

它的一個出現,如果你想你可以添加一個平移手勢識別器,以便用戶可以刷回備份,或者你可以觸發它以編程方式恢復。