2012-09-20 135 views
0

在我的iPhone應用程序中,我在主視圖控制器上有兩個視圖,一個是帶有一些按鈕的普通視圖'a',另一個是scrollView'b'。當我點擊視圖'a'中的按鈕時,我想要顯示帶有動畫的滾動視圖,例如滾動視圖必須從視圖'a'的後面出現,但它從視圖'a'的前部出現。如何從另一個視圖背面動畫滾動視圖

我使用下面的代碼爲動畫滾動視圖。

CGRect Frame = scrollView.frame; 
if(Frame.origin.y == 420){ 
    Frame.origin.y = 298; 
      [UIView animateWithDuration:0.5 animations:^{ 
     scrollView.frame = Frame; 
    }]; 
}else{ 
    Frame.origin.y = 420; 
    [UIView animateWithDuration:0.5 animations:^{ 
     scrollView.frame = Frame; 
    }]; 

如何實現動畫滾動視圖但從「A」頂部表現出來。

回答

0

嘗試 「B」 先移動到後面:

[self.view sendSubviewToBack:scrollview_b]; 
+0

感謝您的解決方案,但它並沒有對我的工作的問題 – smily

0

,我發現我的問題的解決方案。

解決方案:

CGRect Frame = scrollView.frame; 
    if(Frame.origin.y == 420){ 
     Frame.origin.y = 298; 
     [UIView animateWithDuration:0.5 animations:^{ 
      scrollView.frame = Frame; 
      [self.view insertSubview:scrollView belowSubview:view_a]; 
     }]; 

    }else{ 
     Frame.origin.y = 420; 
     [UIView animateWithDuration:0.5 animations:^{ 
      scrollView.frame = Frame; 
      [self.view insertSubview:scrollView belowSubview:view_a]; 
     }]; 
    } 
相關問題