-1

直到 iOS12,我使用以下代码来处理状态栏上的点击事件:

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    super.touchesBegan(touches, with: event)

    let statusBarRect = UIApplication.shared.statusBarFrame
        guard let touchPoint = event?.allTouches?.first?.location(in: self.window) else { return }
        if statusBarRect.contains(touchPoint) {
            //Status bar tapped
        }
    }            
}

但是,现在它不适用于 iOS 13。请帮助我。

4

1 回答 1

0

无法触摸应用中状态栏后面的视图。您不应该在您的应用程序中尝试检测“状态栏上”的点击;它甚至不是您应用程序的一部分(它是运行时强加的窗口)。这是不可能的。

于 2019-12-20T05:58:10.633 回答