The iOS status bar is an interesting construct many jailbreak developers try to avoid messing with. After some research I thought I’d share some of my achievements to help other developers.
Status bars contain so-called items, for example the WiFi item or the battery item, each item has a unique identifier. With some research I found out most items and their corresponding identifier:
|0||time / clock|
|1||quite mode / DND|
|4||service item (carrier name)|
|7||battery icon + lightning|
|9||battery percent, looks same as 8 but isn’t. Maybe the not charging item?|
|20||assistant / Siri|
|23||activity / loading indicator|
|24||thermal color (?)|
What to do with these item identifiers? What about enabling or disabling some items globally? Let’s enable the Siri status bar item:
And ta-da, a siri icon in the status bar:
The status bar gets data from the status bar server
UIStatusBarServer. The server and the status bar are not directly connected, a status bar state provider is a proxy between the two. A state provider conforms to the
UIStatusBarStateProvider protocol, in SpringBoard
SBStatusBarStateProvider and its subclasses (
SBNotificationCenterStatusBarStateProvider). State providers notify listening status bars about changes and edit the data, shwing or hiding specific items.
SBMainStatusBarStateProvider enables and disables the time item dynamically (disabled on the lock screen, enabled otherwise), status bars get data from it by default. Hence to enable or disable the status bar time in (almost) all status bars, call the main state provider:
If you don’t want your status bar to hide the time dynamically, don’t use the main state provider (shown below)!
The status bar can also have different styles, infulencing the foreground and background color or the status bar height (incomplete list!).
|0x12F||Notification center style|
|0x132||Big lockscreen style|
When to use these styles is shown in the next paragraph.
Creating status bars
Creating a status bar isn’t very hard:
1 2 3 4 5 6 7 8 9
In this example we provide a custom state provider, the status bar won’t use the main provider and will always show the time item, even on the lock screen. To use the main provider, initialize the status bar with
Don’t forget to call
-setOrientation: after initialization or if the interface orientation of your interface changed.
I hope this will help some other developers. If you have additions, please let me know about them. Happy coding!