我有一个自定义的 UITabBarController
,很久以前我发现这段代码可以在我按下某个按钮时动画隐藏标签栏。在升级到 iOS 11 之前,这一直很好用,现在当隐藏标签栏时状态栏变为白色。
我不明白发生了什么事。好像Y的view位置增加了20点,在状态栏下方,代码:
extension CustomTabBarController {
func showTabBar(_ notification: Foundation.Notification) {
setTabBarVisible(true, animated: true)
}
func hideTabBar(_ notification: Foundation.Notification) {
setTabBarVisible(false, animated: true)
}
fileprivate func setTabBarVisible(_ visible: Bool, animated: Bool) {
let frame = tabBar.frame
let height = frame.size.height
let offsetY = (visible ? -height : height)
let duration: TimeInterval = (animated ? 0.3 : 0.0)
UIView.animate(withDuration: duration) {
self.tabBar.frame = frame.offsetBy(dx: 0, dy: offsetY)
self.view.frame = CGRect(x: 0.0, y: 0.0, width: self.view.frame.width, height: self.view.frame.height + offsetY)
self.view.setNeedsDisplay()
self.view.layoutIfNeeded()
}
}
}
最佳答案
我在我的 iPhone 6s Plus 上发现了同样的问题。我最初运行的是 iOS 11.0.2,它似乎工作正常。更新到 iOS 11.1.2 后出现问题。这让我相信它是在 11.1 之后引入的。
解决方案:删除这一行似乎给我带来了预期的结果。
self.view.frame = CGRect(x: 0.0, y: 0.0, width: self.view.frame.width, height: self.view.frame.height + offsetY)
希望对你有帮助
- 阿米尔
关于ios - 隐藏标签栏时白色状态栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47136336/