Class

UIBarButtonItem

A button specialized for placement on a toolbar or tab bar.

Declaration

@interface UIBarButtonItem : UIBarItem

Overview

You typically use Interface Builder to create and configure bar button items.

Customizing Appearance

You use the methods listed in Customizing Appearance to customize the appearance of buttons. You send the setter messages to the appearance proxy ([UIBarButtonItem appearance]) to customize all buttons, or to a specific UIBarButtonItem instance. You may use customized buttons in standard places in a UINavigationItem object (backBarButtonItem, leftBarButtonItem, rightBarButtonItem) or a UIToolbar instance.

In general, you should specify a value for the normal state to be used by other states which don’t have a custom value set. Similarly, when a property is dependent on the bar metrics (on iPhone, in landscape orientation bars have a different height from standard), you should specify a value of UIBarMetricsDefault.

For more information about appearance and behavior configuration, see Toolbars.

Topics

Initializing an Item

- initWithBarButtonSystemItem:target:action:

Initializes a new item containing the specified system item.

- initWithCustomView:

Initializes a new item using the specified custom view.

- initWithImage:style:target:action:

Initializes a new item using the specified image and other properties.

- initWithTitle:style:target:action:

Initializes a new item using the specified title and other properties.

- initWithImage:landscapeImagePhone:style:target:action:

Initializes a new item using the specified images and other properties.

- init

Initializes the bar button item to its default state.

Getting and Setting Properties

target

The object that receives an action when the item is selected.

action

The selector defining the action message to send to the target object when the user taps this bar button item.

style

The style of the item.

possibleTitles

The set of possible titles to display on the bar button.

width

The width of the item.

customView

A custom view representing the item.

Customizing Appearance

tintColor

The tint color to apply to the button item.

- backButtonBackgroundImageForState:barMetrics:

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

- setBackButtonBackgroundImage:forState:barMetrics:

Sets the back button background image for a given control state and bar metrics

- backButtonTitlePositionAdjustmentForBarMetrics:

Returns the back button title offset for given bar metrics.

- setBackButtonTitlePositionAdjustment:forBarMetrics:

Sets the back button title offset for given bar metrics

- backButtonBackgroundVerticalPositionAdjustmentForBarMetrics:

Returns the back button vertical position offset for given bar metrics.

- setBackButtonBackgroundVerticalPositionAdjustment:forBarMetrics:

Sets the back button vertical position offset for given bar metrics.

- backgroundVerticalPositionAdjustmentForBarMetrics:

Returns the background vertical position offset for given bar metrics.

- setBackgroundVerticalPositionAdjustment:forBarMetrics:

Sets the background vertical position offset for given bar metrics.

- backgroundImageForState:barMetrics:

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

- setBackgroundImage:forState:barMetrics:

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

- backgroundImageForState:style:barMetrics:

Returns the background image for the specified state, style, and metrics.

- setBackgroundImage:forState:style:barMetrics:

Sets the background image for the specified state, style, and metrics.

- titlePositionAdjustmentForBarMetrics:

Returns the title offset for given bar metrics.

- setTitlePositionAdjustment:forBarMetrics:

Sets the title offset for given bar metrics.

Getting the Shortcuts Group Information

buttonGroup

The group on the shortcuts bar to which the button belongs.

Constants

UIBarButtonSystemItem

Defines system-supplied images for bar button items.

UIBarButtonItemStyle

Specifies the style of an item.

Relationships

Inherits From

Conforms To

See Also

Bars

UIBarItem

An abstract superclass for items that can be added to a bar that appears at the bottom of the screen.

UIBarButtonItemGroup

A set of bar button items on the shortcuts bar above the keyboard on iPad.

UINavigationBar

Navigational controls displayed in a bar along the top of the screen, usually in conjunction with a navigation controller.

UISearchBar

A specialized view for receiving search-related information from the user.

UIToolbar

A control that displays one or more buttons along the bottom edge of your interface.

UITabBar

A control that displays one or more buttons in a tab bar for selecting between different subtasks, views, or modes in an app.

UITabBarItem

An item in a tab bar.

UIBarPositioning

A set of methods for defining the ways that bars can be positioned in iOS apps.

UIBarPositioningDelegate

A set of methods that support the positioning of a bar that conforms to the UIBarPositioning protocol.