Libstatusbar

From iPhone Development Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Libstatusbar
Cydia Package
Developer phoenix3200
Package ID libstatusbar
Latest Version 0.9.7.0


libstatusbar is a library supporting status bar modifications.

The readme explaining iOS 7.x support is at http://phoenix-dev.com/Drop/README (also viewable on the project page on Github).

How to use within a SpringBoard tweak

First download the LSStatusBarItem.h header file. To compile it needs the following modification to the enum:

typedef NS_ENUM(NSInteger, StatusBarAlignment)

Create a singleton class in your tweak. In your tweak initializer, you need to call the shared singleton. Then, in its init method, perform a delayed init method by using:

[self performSelector:@selector(delayedInit) withObject:nil afterDelay:0];

The reason for this is when your tweak is initialized into the SpringBoard, chances are libstatusbar.dylib, which contains the LSStatusBarItem, hasn't been loaded in yet, hence it would be null in the init method. So by delaying a run loop event, it will be loaded and the instance can be successfully created.

-(void)delayedInit{
 self.statusBarItem =  [[NSClassFromString(@"LSStatusBarItem") alloc] initWithIdentifier: @"com.malcolmhall.InsomniaPro" alignment: StatusBarAlignmentRight];
 _statusBarItem.imageName = @"InsomniaPro";
}

The imageName defines what image to look for. See below for naming conventions.

Then when you want to make the status bar item appear, do this:

self.statusBarItem.visible = YES;

I would usually check a setting inside the delayedInit and show it the first time if necessary. The last thing you need to do is add a dependency on libstatusbar in your control file so that when your deb is installed it also installs the dependency so that the NSClassFromString can successfully find the LSStatusBarItem class.

Icon sizes

My iOS 6 icon sizes were 12x20 for 1x and 20x40 for 2x

iOS 7 uses a height of 20 normal and 24 on the lock screen. Some example sizes from the built-in icons are:

Black_Airplane~iphone.png 12x20
[email protected] 26x40
LockScreen_Airplane~iphone.png 14x24
[email protected] 28x48

Black_Alarm~iphone.png 9x20
[email protected] 19x40
LockScreen_Alarm~iphone.png 11x24
[email protected] 27x48

Icon Locations and Naming

3.x style, does not support retina icons: Silver statusbar: /System/Library/CoreServices/SpringBoard/Default_<name>.png Black statusbar: /System/Library/CoreServices/SpringBoard/FSO_<name>.png

4.x style, supports retina (@2x) icons: Silver statusbar: /System/Library/Frameworks/UIKit.framework/Silver_<name>.png Black statusbar: /System/Library/Frameworks/UIKit.framework/Black_<name>.png

5.x style, additionally supports notification center icons: Silver statusbar: /System/Library/Frameworks/UIKit.framework/ColorOnGrayShadow_<name>.png Black statusbar: /System/Library/Frameworks/UIKit.framework/WhiteOnBlackEtch_<name>.png Notif. statusbar: /System/Library/Frameworks/UIKit.framework/WhiteOnBlackShadow_<name>.png

6.x style: Same as 5.x, but the silver statusbar went poof.

7.x style: Take a completely black icon and tint it to the appropriate shade. /System/Library/Frameworks/UIKit.framework/LockScreen_<name>.png /System/Library/Frameworks/UIKit.framework/Black_<name>.png

To support color icons, use the following naming conventions: /System/Library/Frameworks/UIKit.framework/LockScreen_<name>_Color.png /System/Library/Frameworks/UIKit.framework/Black_<name>_Color.png /System/Library/Frameworks/UIKit.framework/White_<name>_Color.png

3.x-6.x styles are cross compatible; 7.x is not. Blame Apple for royally screwing the pooch by using overlapping names with different meanings (black statusbar vs black icon) vs. the 4.x convention. So, for 7.x, please change over/update your icons for the new style.