UIBarButtonItem
A specialized button for placement on a toolbar, navigation bar, or shortcuts bar.
Declaration
@MainActor class UIBarButtonItemMentioned in
Overview
You typically use Interface Builder to create and configure bar button items. However, you can customize the appearance of buttons by sending the setter messages to UIBarButtonItemAppearance to customize all buttons, or to a specific UIBarButtonItem instance. You can use customized buttons in standard places in a UINavigationItem object or a UIToolbar instance.
In general, specify a value for the normal state so that other states without a custom value set can use it. Similarly, when a property depends on the bar metrics (for instance, on the iPhone in landscape orientation, bars have a different height from the standard), specify a value of UIBarMetrics.default.
Topics
Creating items
Creating items of a specific style
init(title:style:target:action:)init(image:style:target:action:)init(image:landscapeImagePhone:style:target:action:)
Creating system items
init(systemItem:primaryAction:menu:)init(barButtonSystemItem:target:action:)UIBarButtonItem.SystemItem
Creating custom items
Creating space items
Creating groups
creatingOptionalGroup(customizationIdentifier:isInDefaultCustomization:)creatingFixedGroup()creatingMovableGroup(customizationIdentifier:)
Managing the custom view
Managing the action
Managing the context menu
Customizing item appearance
Customizing the Back button
backButtonBackgroundImage(for:barMetrics:)setBackButtonBackgroundImage(_:for:barMetrics:)backButtonTitlePositionAdjustment(for:)setBackButtonTitlePositionAdjustment(_:for:)backButtonBackgroundVerticalPositionAdjustment(for:)setBackButtonBackgroundVerticalPositionAdjustment(_:for:)
Customizing the background
backgroundVerticalPositionAdjustment(for:)setBackgroundVerticalPositionAdjustment(_:for:)backgroundImage(for:barMetrics:)setBackgroundImage(_:for:barMetrics:)backgroundImage(for:style:barMetrics:)setBackgroundImage(_:for:style:barMetrics:)
Customizing the title placement
Configuring symbol effects
isSymbolAnimationEnabledaddSymbolEffect(_:options:animated:)addSymbolEffect(_:options:animated:)addSymbolEffect(_:options:animated:)setSymbolImage(_:contentTransition:options:)removeSymbolEffect(ofType:options:animated:)removeSymbolEffect(ofType:options:animated:)removeSymbolEffect(ofType:options:animated:)removeAllSymbolEffects(options:animated:)