1

I'm building a very feature-packed app at the moment and I want to implement a kind of 'go back' action triggered by a gesture recognizer. As the rest of the screen is already used the only place left is the status bar.

So the question is, is it even possible and if so how?

Thanks in advance!

Finn Gaida
  • 4,000
  • 4
  • 20
  • 30

2 Answers2

2

You can place a transparent UIWindow above the status bar, and then give that UIWindow a UISwipeGestureRecognizer.

See MTStatusBarOverlay on how to add a UIWindow over the status bar.

Specifically, create a UIWindow like so:

UIWindow *window = [[UIWindow alloc] init];
window.frame = [[UIApplication sharedApplication] statusBarFrame];
window.windowLevel = UIWindowLevelStatusBar + 1.0f;
[window makeKeyAndVisible];

then add your UISwipeGestureRecognizer to it.

If this doesn't work immediately, you may have to set the backgroundColor property to be non-clear. Clear UIViews pass through touches (although I believe they should still work with UIGestureRecognizers.

Daniel Amitay
  • 6,677
  • 7
  • 36
  • 43
  • It's also worth noting that you may run into problems with your keyboard not entering text if you don't call `resignKeyWindow` on the overlay first. – enjayem Feb 26 '13 at 00:44
0

There is unfortunately no way to detect a swipe on the Status Bar, as it's a component controlled entirely by the operating system itself (similarly to the Multitasking Tray or Notification Center), and isn't under the jurisdiction of an app.

You may be able to throw something together on a jailbroken device, but for a standard iPhone or iPad, there is no (and likely will never be) Public API for interacting with the Status Bar.

username tbd
  • 9,152
  • 1
  • 20
  • 35