Instance Method

setBackgroundImage:forState:barMetrics:

Sets the background image for a given state and bar metrics.

Declaration

- (void)setBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state barMetrics:(UIBarMetrics)barMetrics;

Parameters

backgroundImage

The background image to use for state and barMetrics.

state

A control state.

barMetrics

Bar metrics.

Discussion

If backgroundImage is an image returned from resizableImageWithCapInsets:, the cap widths are calculated from that information.

If backgroundImage is not an image returned from resizableImageWithCapInsets:, the cap width is calculated by subtracting one from the image's width then dividing by 2. The cap widths are used as the margins for text placement. To adjust the margin, use the margin adjustment methods.

Discussion

See Also

Customizing Appearance

- backgroundImageForState:barMetrics:

Returns the background image for a given state and bar metrics.

- contentPositionAdjustmentForSegmentType:barMetrics:

Returns the positioning offset for a given segment and bar metrics.

- setContentPositionAdjustment:forSegmentType:barMetrics:

Returns the content positioning offset for a given segment and bar metrics.

- dividerImageForLeftSegmentState:rightSegmentState:barMetrics:

Returns the divider image used for a given combination of left and right segment states and bar metrics.

- setDividerImage:forLeftSegmentState:rightSegmentState:barMetrics:

Sets the divider image used for a given combination of left and right segment states and bar metrics.

- titleTextAttributesForState:

Returns the text attributes of the title for a given control state.

- setTitleTextAttributes:forState:

Sets the text attributes of the title for a given control state.