在iOS10上滚动正文时,我可以阻止底部菜单栏隐藏吗?

时间:2016-11-09 08:57:29

标签: ios css

在iOS 10 Safari上滚动正文时,底部控件会隐藏。我可以阻止吗?

我需要身体可以滚动。

1 个答案:

答案 0 :(得分:0)

以下是代码

func scrollViewWillBeginDragging(scrollView: UIScrollView) {
    if scrollView.panGestureRecognizer.translationInView(scrollView).y < 0{
        changeTabBar(true, animated: true)
    }
    else{
        changeTabBar(false, animated: true)
    }
}
You can also use the other callback method:

func scrollViewDidScroll(scrollView: UIScrollView) {
    ...
}
but if you choose so, then you most handle multiple calls to the helper method that actually hides the tabBar.

And then you need to add this method that animates the hide/show of the tabBar.

func changeTabBar(hidden:Bool, animated: Bool){
    var tabBar = self.tabBarController?.tabBar
    if tabBar!.hidden == hidden{ return }
    let frame = tabBar?.frame
    let offset = (hidden ? (frame?.size.height)! : -(frame?.size.height)!)
    let duration:NSTimeInterval = (animated ? 0.5 : 0.0)
    tabBar?.hidden = false
    if frame != nil
    {
        UIView.animateWithDuration(duration,
            animations: {tabBar!.frame = CGRectOffset(frame!, 0, offset)},
            completion: {
                println($0)
                if $0 {tabBar?.hidden = hidden}
        })
    }
}