SBIconView

From iPhone Development Wiki
Revision as of 02:50, 6 September 2013 by Kirb (talk | contribs) (Creating Modified Versions: no need to call `class`, objc_getClass() returns a Class anyway)
Jump to: navigation, search

SBIconView is a UIView subclass introduced in iOS 5 that is used to display icons in SpringBoard. In iOS 5 Apple split up the SBIcon, creating a separate class for the view, and just leaving the SBIcon with behind the scenes stuff.

Creating an Instance

   SBIcon *sbicon = [[objc_getClass("SBIconModel") sharedInstance] applicationIconForDisplayIdentifier:@"com.apple.MobileSafari"];
   SBIconView *view = [[objc_getClass("SBIconView") alloc]initWithDefaultSize];
    // set an SBIcon to get the display name and icon image 
    [view setIcon:sbicon];
     view.delegate = self;

Delegate Methods

- (BOOL)iconAllowJitter:(SBIconView *)arg1 {
    
    return YES;
}
- (BOOL)iconPositionIsEditable:(id)arg1 {
    
    return NO;
}
- (void)iconHandleLongPress:(SBIconView *)arg1 {
    
    [arg1 setIsJittering:YES];
}
- (void)iconTouchBegan:(SBIconView *)arg1 {
    [arg1 setHighlighted:YES];
    
    
}
- (void)icon:(id)arg1 touchMovedWithEvent:(id)arg2 {
    
    
}
- (void)icon:(SBIconView *)arg1 touchEnded:(BOOL)arg2 {
    [arg1 setHighlighted:NO delayUnhighlight:NO];

}
- (BOOL)iconShouldAllowTap:(id)arg1 {
    return YES;
}
- (void)iconTapped:(SBIconView *)arg1 {
    [arg1.icon launchFromViewSwitcher];
}
- (BOOL)icon:(id)arg1 canReceiveGrabbedIcon:(id)arg2 {
    return NO;
}

- (int)closeBoxTypeForIcon:(id)arg1 {
    
    return 1;
}
- (void)iconCloseBoxTapped:(id)arg1 {
    
}
- (BOOL)iconShouldPrepareGhostlyImage:(id)arg1 {
    
    return YES;
}
- (BOOL)iconViewDisplaysBadges:(id)arg1 {
    
    return NO;
}

Creating Modified Versions

The SBIconView class can be easily modified by subclassing.

These custom classes can be inserted into SpringBoard by hooking the following method in any class that conforms to the SBIconViewMapDelegate protocol:

- (Class)viewMap:(id)arg1 iconViewClassForIcon:(id)arg2
{
    return objc_getClass("MyClass");
}