Phoenix3200 (talk | contribs) mNo edit summary |
(→How to use within a SpringBoard tweak: or, you know, instead of racing, just dlopen it) |
||
Line 9: | Line 9: | ||
The readme explaining iOS 7.x support is viewable [https://github.com/phoenix3200/libstatusbar on the project page on Github]. | The readme explaining iOS 7.x support is viewable [https://github.com/phoenix3200/libstatusbar on the project page on Github]. | ||
== How to use within a | == How to use within a tweak == | ||
First download the [https:// | First download the [https://github.com/phoenix3200/libstatusbar/blob/master/LSStatusBarItem.h LSStatusBarItem.h] header file. To compile on modern toolchains, the first line must be edited to instead be the following: | ||
<source lang="objc"> | |||
typedef NS_ENUM(NSInteger, StatusBarAlignment) | |||
</source> | |||
Create a | Create a constructor function in your tweak. You need to first ensure libstatusbar is loaded, otherwise the following code most likely won’t work (depending on whether your tweak is loaded after libstatusbar by Substrate, and whether another tweak loaded before yours has already done this). | ||
<source lang="objc"> | |||
dlopen("/Library/MobileSubstrate/DynamicLibraries/libstatusbar.dylib", RTLD_LAZY); | |||
</source> | |||
Use of dlopen() will require you to also <code>#include <dlfcn.h></code>. | |||
After this, you can proceed to create a status bar item. Here is an example: | |||
<source lang="logos"> | |||
statusBarItem = [[%c(LSStatusBarItem) alloc] initWithIdentifier:@"com.malcolmhall.InsomniaPro" alignment:StatusBarAlignmentRight]; | |||
statusBarItem.imageName = @"InsomniaPro"; | |||
</source> | |||
The imageName defines what image to look for. See below for naming conventions. | The imageName defines what image to look for. See below for naming conventions. | ||
The item will be visible by default. You can control this by setting the <code>visible</code> property: | |||
<source lang="objc"> | |||
statusBarItem.visible = NO; | |||
</source> | |||
The last thing you need to do is add a dependency on libstatusbar in your package’s control file. Obviously none of this will work if it’s not installed. That might look something like: | |||
<source lang="text"> | |||
Depends: mobilesubstrate, libstatusbar | |||
</source> | |||
It’s also worth noting that the libstatusbar API is usable from pretty much any process that has permission to do inter-process communication. This includes apps, daemons, and command line tools. | |||
== Icon sizes == | == Icon sizes == |
Revision as of 08:17, 29 April 2016
Libstatusbar | |
Cydia Package | |
---|---|
Developer | phoenix3200 |
Package ID | libstatusbar |
Latest Version | 0.9.8-1 |
libstatusbar is a library supporting status bar modifications.
The readme explaining iOS 7.x support is viewable on the project page on Github.
How to use within a tweak
First download the LSStatusBarItem.h header file. To compile on modern toolchains, the first line must be edited to instead be the following:
typedef NS_ENUM(NSInteger, StatusBarAlignment)
Create a constructor function in your tweak. You need to first ensure libstatusbar is loaded, otherwise the following code most likely won’t work (depending on whether your tweak is loaded after libstatusbar by Substrate, and whether another tweak loaded before yours has already done this).
dlopen("/Library/MobileSubstrate/DynamicLibraries/libstatusbar.dylib", RTLD_LAZY);
Use of dlopen() will require you to also #include <dlfcn.h>
.
After this, you can proceed to create a status bar item. Here is an example:
statusBarItem = [[%c(LSStatusBarItem) alloc] initWithIdentifier:@"com.malcolmhall.InsomniaPro" alignment:StatusBarAlignmentRight];
statusBarItem.imageName = @"InsomniaPro";
The imageName defines what image to look for. See below for naming conventions.
The item will be visible by default. You can control this by setting the visible
property:
statusBarItem.visible = NO;
The last thing you need to do is add a dependency on libstatusbar in your package’s control file. Obviously none of this will work if it’s not installed. That might look something like:
Depends: mobilesubstrate, libstatusbar
It’s also worth noting that the libstatusbar API is usable from pretty much any process that has permission to do inter-process communication. This includes apps, daemons, and command line tools.
Icon sizes
You must provide 2x images, it will not fallback to 1x images on devices with retina screens.
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
Check out https://github.com/phoenix3200/libstatusbar for info on where to put images for different devices, and how to name them.
Video Tutorials
To see a full tutorial on how to use this library in your tweak, check out this video by Sassoty