An item in a tab bar.


class UITabBarItem : UIBarItem


A tab bar operates strictly in radio mode, where one item is selected at a time—tapping a tab bar item toggles the view above the tab bar. You can also specify a badge value on the tab bar item for adding additional visual information—for example, the Messages app uses a badge on the item to show the number of new messages. This class also provides a number of system defaults for creating items.

Use the init(tabBarSystemItem:tag:) method to create one of the system items. Use the init(title:image:tag:) method to create a custom item with the specified title and image, which is used as both the unselected and selected image. Use the init(title:image:selectedImage:) method to create a custom item with the specified title, unselected image, and selected image.

Customizing Appearance

In iOS v5.0 and later, you can customize the appearance of tab bars by setting item label text attributes using appearance selectors declared by UIBarItem. You can also use the methods listed in Customizing Appearance. You can customize the appearance of all tab bar items using the appearance proxy (for example, [UITabBarItem appearance]), or just of a single tab bar item.

By default, unselected and selected images are automatically created from the alpha values in the source images. To prevent system coloring, provide images with UIImage.RenderingMode.alwaysOriginal.

For more information about appearance and behavior configuration, see Tab Bars.


Initializing an Item

init(tabBarSystemItem: UITabBarItem.SystemItem, tag: Int)

Creates and returns a new item containing the specified system item.

init(title: String?, image: UIImage?, tag: Int)

Creates and returns a new item using the specified properties.

init(title: String?, image: UIImage?, selectedImage: UIImage?)

Creates and returns a new item with the specified title, unselected image, and selected image.


Initializes the tab bar item to its default state.

enum UITabBarItem.SystemItem

System items that can be used on a tab bar.

Customizing Appearance

var selectedImage: UIImage?

The image displayed when the tab bar item is selected.

var titlePositionAdjustment: UIOffset

The offset to use to adjust the title position.

struct UIOffset

Defines a structure that specifies an amount to offset a position.

Configuring the Badge

var badgeValue: String?

Text that is displayed in the upper-right corner of the item with a surrounding red oval.

var badgeColor: UIColor?

The background color to apply to the badge.

func badgeTextAttributes(for: UIControl.State) -> [NSAttributedString.Key : Any]?

Retrieves the custom text attributes associated with the item's badge text.

See Also

Tab View Interface

class UITabBarController

A container view controller that manages a radio-style selection interface, where the selection determines which child view controller to display.

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.