Class

UIBarItem

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.

Overview

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]).

Symbols

Getting and Setting Properties

var isEnabled: Bool

A Boolean value indicating whether the item is enabled.

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 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 title: String?

The title displayed on the item.

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([String : 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.