How do I hide/show tabBar when tapped using Swift in iOS8

后端 未结 10 1053
终归单人心
终归单人心 2020-12-04 12:44

I am trying to mimic the UINavigationController\'s new hidesBarsOnTap with a tab bar. I have seen many answers to this that either point to setting the hi

10条回答
  •  生来不讨喜
    2020-12-04 13:07

    For Swift 4, and animating + hiding by placing tabBar outside the view:

    if let tabBar = tabBarController?.tabBar,
       let y = tabBar.frame.origin.y + tabBar.frame.height {
       UIView.animate(withDuration: 0.2) {
         tabBar.frame = CGRect(origin: CGPoint(x: tabBar.frame.origin.x, y: y), size: tabBar.frame.size)
       }
    }
    

提交回复
热议问题