2011-11-29 76 views
1

我正在嘗試動畫我的uitoolbar。我正在嘗試擴展和縮小我的uview。我想要工具欄與視圖一起動畫。但是這裏的uitoolbar首先擴展和合同,然後uiview就是動畫。所以uitoolbar框架根據矩形而改變,但不是動畫。有人可以告訴我,如何動畫uitoolbar。與工具欄一起,我也想爲tabbar設置動畫。我該如何去做這件事。如何動畫uitoolbar

在我看來,我寫了下面的代碼:

[UIView animateWithDuration:1.0 animations:^(void){ 

     [recordDetailView setFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, recordDetailView.frame.size.height)]; 
     [normalModeToolbar setFrame:CGRectMake(0.0, 0.0,self.view.frame.size.width, 49)]; 
     [self.view bringSubviewToFront:recordDetailView]; 
    } completion:^(BOOL finished){ 
    } 
    ]; 

回答

0

您是否嘗試過使用範圍呢?

[UIView animateWithDuration:1.0 animations:^(void){ 
    yourView.bounds = CGRectMake(yourView.bounds.origin.x, 
           yourView.bounds.origin.y, 
           yourView.bounds.size.width * 2, // target width 
           yourView.bounds.size.height); 
}]; 

此外,我也想嘗試啓動動畫之前把你recordDetailView前面。

+0

frame is animaimatable。你對CALayer和UIView類感到困惑。 – beryllium

+0

啊,謝謝你的提示!那麼我如何知道UIView的動畫屬性呢? – zlajo

+0

[什麼是動畫?](http://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/AnimatingViews/AnimatingViews.html#//apple_ref/doc/uid/TP40009503-CH6-SW2 ) – beryllium

1

UIViewAnimationOptionLayoutSubviews(iOS> 4.0)應該在大小更改未動畫時解決問題。

[UIView animateWithDuration:1.0 
     delay:0 
     options:UIViewAnimationOptionLayoutSubviews 
     animations:^{ 
      [recordDetailView setFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width,     recordDetailView.frame.size.height)]; 
      [normalModeToolbar setFrame:CGRectMake(0.0, 0.0,self.view.frame.size.width, 49)]; 
     } 
     completion:nil 
];