如何在iOS13中检测状态栏点击?

问题描述 投票:0回答: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) {
            NotificationCenter.default.post(statusBarTappedNotification)
        }
}

但是它在iOS13中不再起作用。有什么想法吗?

swift status ios13
1个回答
0
投票

我已经能够用Objective-C类别为UIStatusBarManager来检测抽头。我认为这不是快速扩展或其他快速方式的可能性。

@implementation UIStatusBarManager (CAPHandleTapAction)
-(void)handleTapAction:(id)arg1 {
    // Your code here
}
@end
© www.soinside.com 2019 - 2024. All rights reserved.