Search code examples
swiftstatusbaruistatusbar

Perform action when status bar is clicked


I have seen popular apps like messenger do something with their status bar. When you call someone and go out of the app, there is a red status bar. If you click on it you get back to the app. I have been searching on performing actions when the status bar is clicked. I am not sure if it even involves the status bar. Anyway, if you know how to perform an action, it would be nice to help me out:) I don’t want to seem like to just posting here because i am to lazy. It was actually hard to find information about this.


Solution

  • The status bar is a part of the iOS platform and has really nothing to do with your app. The only thing you can really control is its appearance. The 'different' status bars you see during different instances like when you're on a phone call or when your location is being tracked etc. are all driven by the OS itself.

    If you really need to add an action to the status bar, you're better of using a 'fake' transparent view over the status bar and adding a gesture to it, rather than capturing it as one of UIApplication's subviews. This is an example of private API usage. Apple has always been against such practices, and has even rejected apps in certain cases.