UIBarItem Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/UIKit.framework |
| Availability | Available in iOS 2.0 and later. |
| Declared in | UIBarItem.h |
Overview
UIBarItem is an abstract superclass for items added to a bar that appears at the bottom of the screen. Items on a bar behave in a way similar to buttons (instances of UIButton). They have a title, image, action, and target. You can also enable and disable an item on a bar.
Customizing Appearance
You can customize the image to represent the item, and the position of the image, using imageand imageInsets respectively.
In iOS v5.0 and later, you can also specify a custom image and position to use in landscape orientation when using the iPhone appearance idiom using landscapeImagePhoneand landscapeImagePhoneInsets respectively. In addition, you can customize the title’s text attributes using setTitleTextAttributes:forState:, either for a single item, or for all items by using the appearance proxy (for example, [UIBarItem appearance]).
Tasks
Getting and Setting Properties
-
enabledproperty -
imageproperty -
landscapeImagePhoneproperty -
imageInsetsproperty -
landscapeImagePhoneInsetsproperty -
titleproperty -
tagproperty
Customizing Appearance
Properties
enabled
A Boolean value indicating whether the item is enabled.
Discussion
If NO, the item is drawn partially dimmed to indicate it is disabled. The default value is YES.
Availability
- Available in iOS 2.0 and later.
Declared In
UIBarItem.himage
The image used to represent the item.
Discussion
This image can be used to create other images to represent this item on the bar—for example, a selected and unselected image may be derived from this image. You should set this property before adding the item to a bar. The default value is nil.
Availability
- Available in iOS 2.0 and later.
Declared In
UIBarItem.himageInsets
The image inset or outset for each edge.
Discussion
The default value is UIEdgeInsetsZero.
Availability
- Available in iOS 2.0 and later.
Declared In
UIBarItem.hlandscapeImagePhone
The image to use to represent the item in landscape orientation when using the iPhone appearance idiom.
Discussion
This image can be used to create other images to represent this item on the bar—for example, a selected and unselected image may be derived from this image. You should set this property before adding the item to a bar. The default value is nil.
Availability
- Available in iOS 5.0 and later.
Declared In
UIBarItem.hlandscapeImagePhoneInsets
The image inset or outset for each edge of the image in landscape orientation when using the iPhone appearance idiom.
Discussion
The default value is UIEdgeInsetsZero.
Availability
- Available in iOS 5.0 and later.
Declared In
UIBarItem.htag
The receiver’s tag, an application-supplied integer that you can use to identify bar item objects in your application.
Discussion
The default value is 0.
Availability
- Available in iOS 2.0 and later.
Declared In
UIBarItem.htitle
The title displayed on the item.
Discussion
You should set this property before adding the item to a bar. The default value is nil.
Availability
- Available in iOS 2.0 and later.
Declared In
UIBarItem.hInstance Methods
setTitleTextAttributes:forState:
Sets the title’s text attributes for a given control state.
Parameters
- attributes
A dictionary containing key-value pairs for text attributes.
You can specify the font, text color, text shadow color, and text shadow offset using the keys listed in NSString UIKit Additions Reference.
- state
The control state for which you want to set the text attributes for the title.
Availability
- Available in iOS 5.0 and later.
See Also
Declared In
UIBarItem.htitleTextAttributesForState:
Returns the title’s text attributes for a given control state.
Parameters
- state
The control state for which you want to know the text attributes for the title.
Return Value
The title’s text attributes for state.
Discussion
The dictionary may contain key-value pairs for text attributes for the font, text color, text shadow color, and text shadow offset using the keys listed in NSString UIKit Additions Reference.
Availability
- Available in iOS 5.0 and later.
See Also
Declared In
UIBarItem.h© 2011 Apple Inc. All Rights Reserved. (Last updated: 2011-10-12)