我試圖將選項卡欄從屏幕底部的下方移動到頂部,同時調整視圖的高度以縮小標籤欄的高度。實質上,我有一個「隱藏」標籤欄,當它被取消隱藏時,應該在視圖中進行動畫處理,並且displayView應該調整標籤欄現在佔用的空間。UIView子視圖不平滑地動畫
但是,動畫對於顯示視圖來說是跳動的。看起來顯示視圖動畫很好,但子視圖自動調整它們的高度而沒有任何動畫。任何方向修復這一點將不勝感激。
我會接受援助在objective-c或swift中,因爲翻譯相當簡單。
//Displays tab bar with slide up animation. If animated is false, all other params are unused
func displayTabBar(animated:Bool, duration:NSTimeInterval = 0.5, delay:NSTimeInterval = 0, options:UIViewAnimationOptions = UIViewAnimationOptions.CurveLinear, completion:((Bool) -> Void)? = nil){
if(animated){
UIView.animateWithDuration(duration, delay: delay, options: options, animations: {
self.adjustTabBarDisplayed()
}, completion: completion)
UIView.animateWithDuration(duration, delay: delay, options: options, animations: {
self.adjustDisplayViewTabDisplayed()
}, completion: nil)
}
else{
self.adjustTabBarDisplayed()
self.adjustDisplayViewTabDisplayed()
}
}
//Adjusts frame of tab bar to display tab bar
private func adjustTabBarDisplayed(){
self.tabBar.frame = CGRectMake(0,UIScreen.mainScreen().bounds.height - self.tabBar.bounds.height, self.tabBar.bounds.width, self.tabBar.bounds.height)
}
//Adjusts frame of display view to match displayed tab bar
private func adjustDisplayViewTabDisplayed(){
self.displayView.frame = CGRectMake(0,0,self.displayView.bounds.width, UIScreen.mainScreen().bounds.height - self.tabBar.bounds.height)
}