The iOS framework that grows only as fast as its documentation
Button Utilities

Functions

void NIApplyImageSelectorToButton (SEL selector, id target, UIButton *button)
 
void NIApplyBackgroundImageSelectorToButton (SEL selector, id target, UIButton *button)
 
void NIApplyTitleColorSelectorToButton (SEL selector, id target, UIButton *button)
 

Overview

For manipulating UIButton objects.

The methods provided here make it possible to specify different properties for different button states in a scalable way. For example, you can define a stylesheet class that has a number of class methods that return the various properties for buttons.

@implementation Stylesheet
+ (UIImage *)backgroundImageForButtonWithState:(UIControlState)state {
if (state & UIControlStateHighlighted) {
return [UIImage imageNamed:@"button_highlighted"];
} else if (state == UIControlStateNormal) {
return [UIImage imageNamed:@"button"];
}
return nil;
}
@end
// The result of the implementation above will set the background images for the button's
// highlighted and default states.
NIApplyBackgroundImageSelectorToButton(@selector(backgroundImageForButtonWithState:),
[Stylesheet class],
button);

Function Documentation

NIApplyImageSelectorToButton

Sets the images for a button's states.

void NIApplyImageSelectorToButton;
Discussion
Parameters
selectorA selector of the form: (UIImage *)imageWithControlState:(UIControlState)controlState
targetThe target upon which the selector will be invoked.
buttonThe button object whose properties should be modified.

NIApplyBackgroundImageSelectorToButton

Sets the background images for a button's states.

void NIApplyBackgroundImageSelectorToButton;
Discussion
Parameters
selectorA selector of the form: (UIImage *)backgroundImageWithControlState:(UIControlState)controlState
targetThe target upon which the selector will be invoked.
buttonThe button object whose properties should be modified.

NIApplyTitleColorSelectorToButton

Sets the title colors for a button's states.

void NIApplyTitleColorSelectorToButton;
Discussion
Parameters
selectorA selector of the form: (UIColor *)colorWithControlState:(UIControlState)controlState
targetThe target upon which the selector will be invoked.
buttonThe button object whose properties should be modified.