Swift UITabBarController隐藏动画 [英] Swift UITabBarController hide with animation

查看:54
本文介绍了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.

这篇关于Swift UITabBarController隐藏动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆