Class

UIToolbar

A toolbar is a control that displays one or more buttons, called toolbar items. A toolbar momentarily highlights or does not change the appearance of an item when tapped.

Overview

To create toolbar items, use the UIBarButtonItem class. To add toolbar items to a toolbar, use the setItems(_:animated:) method.

Toolbar images that represent normal and highlighted states of an item derive from the image you set using the inherited image property from the UIBarItem class. In iOS 7.0, the image is colored with the toolbar’s tintColor.

If you need radio button style controls, use the UITabBar class instead of UIToolbar.

Customizing Appearance

You use the methods listed in Customizing Appearance to customize the appearance of toolbars. You send the setter messages to the appearance proxy ([UIToolbar appearance]) to customize all toolbars, or to a specific UIToolbar instance. When a property is dependent on the bar metrics (on iPhone, in landscape orientation bars have a different height from standard), you should typically specify a value for default as well as forlandscapePhone.

For more information about appearance and behavior configuration, see Toolbars.

Symbols

Configuring Toolbar Items

var items: [UIBarButtonItem]?

The items displayed on the toolbar.

func setItems([UIBarButtonItem]?, animated: Bool)

Sets the items on the toolbar by animating the changes.

Customizing Appearance

var barStyle: UIBarStyle

The toolbar style that specifies its appearance.

var barTintColor: UIColor?

The tint color to apply to the toolbar background.

var tintColor: UIColor!

The tint color to apply to the bar button items.

var isTranslucent: Bool

A Boolean value that indicates whether the toolbar is translucent (true) or not (false).

func backgroundImage(forToolbarPosition: UIBarPosition, barMetrics: UIBarMetrics)

Returns the image to use for the background in a given position and with given metrics.

func setBackgroundImage(UIImage?, forToolbarPosition: UIBarPosition, barMetrics: UIBarMetrics)

Sets the image to use for the background in a given position and with given metrics.

func shadowImage(forToolbarPosition: UIBarPosition)

Returns the image to use for the toolbar shadow in a given position.

func setShadowImage(UIImage?, forToolbarPosition: UIBarPosition)

Sets the image to use for the toolbar shadow in a given position.

Managing the Delegate

var delegate: UIToolbarDelegate?

The toolbar’s delegate object.