我试图将选项卡栏从屏幕底部的下方移动到顶部,同时调整视图的高度以缩小标签栏的高度。实质上,我有一个“隐藏”标签栏,当它被取消隐藏时,应该在视图中进行动画处理,并且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)
}