首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在iOS10上滚动正文时,是否可以停止隐藏底部菜单栏?

在iOS10上滚动正文时,是否可以停止隐藏底部菜单栏?
EN

Stack Overflow用户
提问于 2016-11-09 16:57:29
回答 1查看 409关注 0票数 0

当你在iOS 10Safari上滚动车身时,底部的控件会隐藏起来。我能防止这种情况发生吗?

我需要身体是可滚动的。

EN

回答 1

Stack Overflow用户

发布于 2016-11-09 17:11:34

这里是代码

代码语言:javascript
复制
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}
        })
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40503010

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档