使用滑动隐藏的 UINavigationBar 会留下一个拦截水龙头以显示它的区域?

A UINavigationBar that hides using swipes leaves a region that intercepts taps to reveal it?

我已将我的 UINavigationController 配置为在滑动时自动隐藏它的 UINavigationBar。上下滑动 hides/reveals 栏就好了。但是,在之前由导航栏 占据的屏幕区域中点击(触摸)也会触发导航栏显示,这给我带来了问题。我的视图在屏幕顶部附近放置了一个按钮。当整个应用程序扩展到自动隐藏的 UINavigationBar 留下的 space 时, 点击我的按钮会触发导航栏显示 这非常烦人,因为我想要滑动揭示酒吧不水龙头。我假设发生这种情况是因为该按钮已向上移动到导航栏所在的 space 中。

有什么方法可以防止点击我的按钮时显示栏吗?我想知道我是否应该覆盖 UINavigationController 中的 hitTest 以尝试阻止事件传播?

这是我隐藏导航栏的方式:

let navVC = self.navigationController
navVC!.hidesBarsOnSwipe = true
navVC!.hidesBarsOnTap = false

如果我使用 RxSwift 订阅 UINavigationController 的控制事件,我会看到这样的事件:

received <_UIBarTapGestureRecognizer: 0x7b6dae30; state = Ended;
    cancelsTouchesInView = NO; view = <UILayoutContainerView 0x7b942bc0>; 
    targets= <("(action=_gestureRecognizedToggleVisibility:, 
        target=<UINavigationController 0x7da79400>)", "(action=eventHandler:, 
        target=<RxCocoa.GestureTarget 0x7b6e1f90>)")>>
    tapCategory=WhereNavigationBarWas

好吧,看起来 UINavBar space 没有什么可以做的,除了不让急救人员移动到那里。我最终将我的按钮移动到受影响视图上的另一个位置,这解决了我的问题。我和我的搭档更喜欢新的布局,这是一个额外的好处。谢谢大家!