Created
June 3, 2017 14:27
-
-
Save alfian0/962eadfd985402f87c8f4fc4ce3d14cc to your computer and use it in GitHub Desktop.
Hide UITabBarController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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