I have a custom UITabBarController
and I found this code a long time ago to animated hide tab bar when I press some button. This works very well until upgrade to iOS 11 and now the status bar turns white when tab bar is hidden.
I can't figure out what happened. It's like Y position of view increase 20 points, below the status bar and code:
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()
}
}
}