Swift UITabBarController隐藏动画
我正尝试在隐藏时将动画添加到我的tabBarController中.我可以通过使用 self.navigationController?.isNavigationBarHidden = true
来使用 navigationBarController
实现此效果.我可以通过使用 self.tabBarController?.tabBar.isHidden = true
隐藏tabBar,但我没有获得动画,我该怎么做呢?
I'm trying to add animation to my tabBarController when hidden. Im able to accomplish this effect with the navigationBarController
by using self.navigationController?.isNavigationBarHidden = true
. I'm able to hide the tabBar by using self.tabBarController?.tabBar.isHidden = true
but i do not get the animation how can I do this thank you in advance.
您可以在动画中更改标签栏的框架,例如:
You could change the tab bar's frame inside an animation, so something like:
func hideTabBar() {
var frame = self.tabBarController?.tabBar.frame
frame?.origin.y = self.view.frame.size.height + (frame?.size.height)!
UIView.animate(withDuration: 0.5, animations: {
self.tabBarController?.tabBar.frame = frame!
})
}
func showTabBar() {
var frame = self.tabBarController?.tabBar.frame
frame?.origin.y = self.view.frame.size.height - (frame?.size.height)!
UIView.animate(withDuration: 0.5, animations: {
self.tabBarController?.tabBar.frame = frame!
})
}
将标签栏设置在可见屏幕的正下方,以便它从底部向上/向下滑动.
Which sets the tab bar just below the visible screen, so that it slides up/down from the bottom.