Skip to content

Instantly share code, notes, and snippets.

@alfian0
Created June 3, 2017 14:27
Show Gist options
  • Select an option

  • Save alfian0/962eadfd985402f87c8f4fc4ce3d14cc to your computer and use it in GitHub Desktop.

Select an option

Save alfian0/962eadfd985402f87c8f4fc4ce3d14cc to your computer and use it in GitHub Desktop.
Hide UITabBarController
extension UITabBarController {
func setTabBarVisible(visible:Bool, animated:Bool) {
let frame = self.tabBar.frame
let height = frame.size.height
let offsetY = (visible ? -height : height)
UIView.animate(withDuration: animated ? 0.3 : 0.0) {
self.tabBar.frame = frame.offsetBy(dx: 0, dy: offsetY)
self.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height + offsetY)
self.view.setNeedsDisplay()
self.view.layoutIfNeeded()
}
}
func tabBarIsVisible() ->Bool {
return self.tabBar.frame.origin.y < self.view.frame.maxY
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment