1

I have a UITabBarController and I added a view controller. In my UIViewController I have a UITableView.

My requirement is whenever I will scroll down tableView then Tab bar should be hidden and TableView should come at full screen and when I scroll tableView up then TabBar should not be hidden.

Here is my story-board screen shots:

enter image description here

enter image description here

In Images you can see I have taken tableView and tabBar. And also TableView height I have to show full when TabBar will be hidden.

Here is my code:

//Change Tab bar
func changeTabBar(hidden:Bool, animated: Bool){
    let tabBar = self.tabBarController?.tabBar
    if tabBar!.isHidden == hidden{ return }
    let frame = tabBar?.frame
    let offset = (hidden ? (frame?.size.height)! : -(frame?.size.height)!)
    let duration:TimeInterval = (animated ? 0.5 : 0.0)
    tabBar?.isHidden = false
    if frame != nil
    {
        UIView.animate(withDuration: duration,
                       animations: {
                        tabBar!.frame = frame!.offsetBy(dx: 0, dy: offset)
                        //tabBar?.isHidden = true
                        //self.tableView.frame.size.height = self.tableView.frame.size.height + (tabBar?.frame.size.height)!
        },
                       completion: {

                        if $0 {tabBar?.isHidden = hidden}
        })
    }
}  

//ScrollView Delegate
extension reNewView : UIScrollViewDelegate {

  //Tab bar
  func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
      if scrollView.panGestureRecognizer.translation(in: scrollView).y < 0{

          changeTabBar(hidden: true, animated: true)
      }
      else{

          changeTabBar(hidden: false, animated: true)
      }
   }
 }  

What to do ?

I checked this link also but still not getting proper answer.

halfer
  • 19,824
  • 17
  • 99
  • 186
Kishor Pahalwani
  • 1,010
  • 1
  • 23
  • 53

0 Answers0