在继承至 UITabBarController的类中隐藏tabB
2017-06-15 本文已影响0人
文瑶906
func setTabBarVisible(visible:Bool,animated:Bool) {
if (tabBarIsVisible() == visible) { return }
let frame = tabBar.frame
let offsetY = (visible ? -49.0 : 49.0)
let duration:TimeInterval = (animated ? 0.3 : 0.0)
if frame != nil {
UIView.animate(withDuration: duration) {
self.tabBar.frame = frame.offsetBy(dx: 0, dy: CGFloat(offsetY))
return
}
}
}
func tabBarIsVisible() -> Bool{
let tabbarY = tabBar.frame.origin.y
print("tabbarY = \(tabbarY)")
return tabbarY < self.view.frame.maxY //self.view.frame.maxY
}