直到 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。请帮助我。