Class

UIBarItem

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

Overview

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(_:for:), either for a single item, or for all items by using the appearance proxy (for example, [UIBarItem appearance]).

Topics

Initializing a Bar Item

init()

Initializes the bar item to its default state.

Getting and Setting Properties

var title: String?

The title displayed on the item.

var image: UIImage?

The image used to represent the item.

var landscapeImagePhone: UIImage?

The image to use to represent the item in landscape orientation when using the iPhone appearance idiom.

var largeContentSizeImage: UIImage?

The image to display for users with visual impairments.

var imageInsets: UIEdgeInsets

The image inset or outset for each edge.

var landscapeImagePhoneInsets: UIEdgeInsets

The image inset or outset for each edge of the image in landscape orientation when using the iPhone appearance idiom.

var largeContentSizeImageInsets: UIEdgeInsets

The insets to apply to the bar item's large image when displaying the image in an assistive UI.

var isEnabled: Bool

A Boolean value indicating whether the item is enabled.

var tag: Int

The receiver’s tag, an application-supplied integer that you can use to identify bar item objects in your application.

Customizing Appearance

func setTitleTextAttributes([NSAttributedStringKey : Any]?, for: UIControlState)

Sets the title’s text attributes for a given control state.

func titleTextAttributes(for: UIControlState)

Returns the title’s text attributes for a given control state.

See Also

Bars

class UIBarButtonItem

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

class UIBarButtonItemGroup

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

class UINavigationBar

A control that supports navigation of hierarchical content, most often used in navigation controllers.

class UISearchBar

A text field–like control that supports text-based searches.

class UIToolbar

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

class UITabBar

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

class UITabBarItem

An item in a tab bar.

protocol UIBarPositioning

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

protocol UIBarPositioningDelegate

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