tristanhimmelman / HidingNavigationBar

Easily hide and show a view controller's navigation bar (and tab bar) as a user scrolls
MIT License
1.03k stars 127 forks source link

hide tabbar only mode #46

Open ShawnBaek opened 8 years ago

ShawnBaek commented 8 years ago

I want hide only tabbar

is there a way to this feature?

Joker666 commented 8 years ago

+1

suhitp commented 8 years ago

Hiding tabBar can be done just by implementing scrollViewDelegate methods and animating the tabBar origin or frame with animation

    //MARK: UIScrollViewDelegate
    func scrollViewWillBeginDecelerating(scrollView: UIScrollView) {
        if scrollView.panGestureRecognizer.translationInView(scrollView).y < 0 {
            showHideTabBar(hidden: true, animated: true)
        }
        else {
            showHideTabBar(hidden: false, animated: true)
        }
    }

    func showHideTabBar(hidden hide: Bool, animated: Bool) {
        var originY: CGFloat = 0
        if hide {
            originY = (self.view.frame.height)
        } else {
            originY = (self.view.frame.height) - 49
        }

        UIView.animateWithDuration(0.25, delay: 0, options: .CurveEaseIn, animations: {
            self.tabBarController?.tabBar.frame.origin.y = originY
        }, completion: nil)
     }