| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/UIKit.framework |
| Availability | Available in iPhone OS 2.0 and later. |
| Declared in | UIBarButtonItem.h |
| Related sample code |
The UIBarButtonItem class encapsulates the properties and behaviors of items added to UIToolbar and UINavigationBar objects. It inherits basic button behavior from its parent class. This class defines additional initialization methods and properties for use on tab bars and navigation bars that allow more custom views.
– initWithBarButtonSystemItem:target:action:
– initWithCustomView:
– initWithImage:style:target:action:
– initWithTitle:style:target:action:
target property
action property
style property
possibleTitles property
width property
customView property
For more about Objective-C properties, see “Properties” in The Objective-C Programming Language.
The selector defining the action message to send to the target object when the user taps this bar button item.
@property(nonatomic) SEL action
If the value of this property is NULL, no action message is sent. The default value is NULL.
UIBarButtonItem.hA custom view representing the item.
@property(nonatomic, retain) UIView *customView
UIBarButtonItem.hCollection of possible titles to display on the bar.
@property(nonatomic, copy) NSSet *possibleTitles
UIBarButtonItem.hThe style of the item.
@property(nonatomic) UIBarButtonItemStyle style
One of the constants defined in UIBarButtonItemStyle. The default value is UIBarButtonItemStylePlain.
UIBarButtonItem.hThe object that receives an action when the item is selected.
@property(nonatomic, assign) id target
If nil, the action message is passed up the responder chain where it may be handled by any object implementing a method corresponding to the selector held by the action property. The default value is nil.
UIBarButtonItem.hThe width of the item.
@property(nonatomic) CGFloat width
If this property value is positive, the width of the combined image and title are fixed. If the value is 0.0 or negative, the item sets the width of the combined image and title to fit. This property is ignored if the style uses radio mode. The default value is 0.0.
UIBarButtonItem.hCreates and returns a new item containing the specified system item.
- (id)initWithBarButtonSystemItem:(UIBarButtonSystemItem)systemItem target:(id)target action:(SEL)action
The system item to use as the first item on the bar. One of the constants defined in UIBarButtonSystemItem.
The object that receives the action message.
The action to send to target when this item is selected.
A newly initialized item containing the specified system item. The item’s target is nil.
UIBarButtonItem.hCreates and returns a new item using the specified custom view.
- (id)initWithCustomView:(UIView *)customView
A custom view representing the item.
Newly initialized item with the specified properties.
UIBarButtonItem.hCreates and returns a new item using the specified image and other properties.
- (id)initWithImage:(UIImage *)image style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action
The item’s image. If nil an image is not displayed.
The images displayed on the bar are derived from this image. If this image is too large to fit on the bar, it is scaled to fit. Typically, the size of a toolbar and navigation bar image is 20 x 20 points. The alpha values in the source image are used to create the images—opaque values are ignored.
The style of the item. One of the constants defined in UIBarButtonItemStyle.
The object that receives the action message.
The action to send to target when this item is selected.
Newly initialized item with the specified properties.
UIBarButtonItem.hCreates and returns a new item using the specified title and other properties.
- (id)initWithTitle:(NSString *)title style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action
The item’s title. If nil a title is not displayed.
The style of the item. One of the constants defined in UIBarButtonItemStyle.
The object that receives the action message.
The action to send to target when this item is selected.
Newly initialized item with the specified properties.
UIBarButtonItem.hDefines system defaults for commonly used items.
typedef enum {
UIBarButtonSystemItemDone,
UIBarButtonSystemItemCancel,
UIBarButtonSystemItemEdit,
UIBarButtonSystemItemSave,
UIBarButtonSystemItemAdd,
UIBarButtonSystemItemFlexibleSpace,
UIBarButtonSystemItemFixedSpace,
UIBarButtonSystemItemCompose,
UIBarButtonSystemItemReply,
UIBarButtonSystemItemAction,
UIBarButtonSystemItemOrganize,
UIBarButtonSystemItemBookmarks,
UIBarButtonSystemItemSearch,
UIBarButtonSystemItemRefresh,
UIBarButtonSystemItemStop,
UIBarButtonSystemItemCamera,
UIBarButtonSystemItemTrash,
UIBarButtonSystemItemPlay,
UIBarButtonSystemItemPause,
UIBarButtonSystemItemRewind,
UIBarButtonSystemItemFastForward,
UIBarButtonSystemItemUndo, // iPhoneOS 3.0
UIBarButtonSystemItemRedo, // iPhoneOS 3.0
} UIBarButtonSystemItem;
UIBarButtonSystemItemDoneThe system Done button. Localized.
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemCancelThe system Cancel button. Localized.
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemEditThe system Edit button. Localized.
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemSaveThe system Save button. Localized.
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemAddThe system plus button containing an icon of a plus sign. ![]()
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemFlexibleSpaceBlank space to add between other items. The space is distributed equally between the other items. Other item properties are ignored when this value is set.
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemFixedSpaceBlank space to add between other items. Only the width property is used when this value is set.
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemComposeThe system compose button. ![]()
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemReplyThe system reply button. ![]()
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemActionThe system action button. ![]()
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemOrganizeThe system organize button. ![]()
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemBookmarksThe system bookmarks button. ![]()
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemSearchThe system search button. ![]()
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemRefreshThe system refresh button. ![]()
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemStopThe system stop button. ![]()
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemCameraThe system camera button. ![]()
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemTrashThe system trash button. ![]()
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemPlayThe system play button. ![]()
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemPauseThe system pause button. ![]()
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemRewindThe system rewind button. ![]()
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemFastForwardThe system fast forward button. ![]()
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemUndoThe system undo button.
Available in iPhone OS 3.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonSystemItemRedoThe system redo button.
Available in iPhone OS 3.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonItem.hSpecifies the style of a item.
typedef enum {
UIBarButtonItemStylePlain,
UIBarButtonItemStyleBordered,
UIBarButtonItemStyleDone,
} UIBarButtonItemStyle;
UIBarButtonItemStylePlainGlows when tapped. The default item style.
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonItemStyleBorderedA simple button style with a border.
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonItemStyleDoneThe style for a done button—for example, a button that completes some task and returns to the previous view.
Available in iPhone OS 2.0 and later.
Declared in UIBarButtonItem.h.
UIBarButtonItem.hLast updated: 2009-05-06