如何监听状态栏的点击

https://www.zybuluo.com/keenleung/note/339982

  • 注意点:

    • 无法从控制器中获取状态栏
    • 状态栏是属于一整个应用程序的,需要在 AppDelegate监听其状态
  • 做法:

/**
* 可以在这个AppDelegate方法中监听到状态栏的点击
*/
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
// 防止事件的传递过程中, 某些控制器的点击事件传递到 AppDelegate 中
if ([touches.anyObject locationInView:nil].y > 20) return;
NSLog(@"点击了状态栏")
}
原文地址:https://www.cnblogs.com/KeenLeung/p/5373837.html