namedfork.net

Trace: » SBCustomIcon


SBCustomIcon

SBCustomIcon is a MobileSubstrate-based extension that allows iPhone applications to easily change their icon in SpringBoard.

Requirements

  • Jailbroken iPhone or iPod touch (OS 2.0 to 3.1.2)
  • MobileSubstrate

How it Works

SBCustomIcon adds the following methods to the UIApplication class for customizing the app icon:

  • - (BOOL)hasCustomIcon;
    returns YES if the application currently has a custom icon, NO otherwise
  • - (BOOL)setCustomIcon:(UIImage*)customIcon;
    sets the app's icon to customIcon
    returns YES on success, NO on failure
  • - (BOOL)setCustomIconFile:(NSString*)customIconPath;
    sets the app's icon to the file at customIconPath, that should be a PNG file
    returns YES on success, NO on failure
  • - (void)removeCustomIcon;
    removes the custom icon for the application, turning it back to the default

The app will also need the following keys in it's Info.plist:

  • SBWillUseCustomIcon (boolean)
    set to YES if your application uses SBCustomIcon functionality
  • SBCustomIconIsPersistent (boolean)
    By default, the icon turns back to normal when the app terminates. If you want it to persist, add this key and set it to YES

You can determine if SBCustomIcon is available before calling any of its methods with the SBCustomIconAvailable macro, or check if the methods exists with respondsToSelector:. Like that your application can work even if the extension isn't installed.

Header

To use SBCustomIcon in your project, include this header file:

UIApplication-SBCustomIcon.h

#import <UIKit/UIKit.h>
#import <objc/runtime.h>
 
#define SBCustomIconAvailable (class_respondsToSelector(objc_getClass("UIApplication"), @selector(hasCustomIcon)))
 
@interface UIApplication (SBCustomIcon)
- (BOOL)hasCustomIcon;
- (BOOL)setCustomIcon:(UIImage*)customIcon;
- (BOOL)setCustomIconFile:(NSString*)customIconPath;
- (void)removeCustomIcon;
@end

Installation

You can find SBCustomIcon in the BigBoss & Planet-iPhones repository in Cydia, or download the deb here and install it manually:

SBCustomIcon sbcustomicon-1.0.deb (13 KiB) SHA1 c187a6663913cbf7746605376259d6813b748afa

License

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You are free to use the functionality of SBCustomIcon in your own software. The source code is provided as reference, but distribution of modified versions is not allowed, since it could create conflicts.

Source Code

  • You can check out the source code from subversion:
    svn checkout svn://vc.namedfork.net/namedfork/sbcustomicon/tags/1.0
  • Or browse and download it with WebSVN:
    http://vc.namedfork.net/nf/sbcustomicon/