UIBarPositioning Protocol Reference

Adopted by
Conforms to
Availability
Available in iOS 7.0 and later.
Declared in
UIBarCommon.h

Overview

The UIBarPositioning protocol defines the ways that bars can be positioned on iOS devices. Bars can be positioned at the bottom of their enclosing view, at the top of their enclosing view, or at both the top of their enclosing view and also the top of the screen. In this last case, the bar will abut the status bar displayed by the system. Bars in this position need to have their background extend above their own frame to the top of the screen. This allows the background to show through the status bar.

The classes that implement bars have paired methods to set a background for a given position and set of metrics. These are named similar to the following: backgroundImageForBarPosition:barMetrics: and setBackgroundImage:forBarPosition:barMetrics:. Use these methods to set an appropriate background image for the different possible bar positions and metrics.

Tasks

Accessing the Bar Position

Properties

barPosition

The position of the bar. (required)

@property(nonatomic,readonly) UIBarPosition barPosition
Availability
  • Available in iOS 7.0 and later.
Declared In
UIBarCommon.h

Constants

UIBarMetrics

Constants to specify metrics to use for appearance.

typedef enum : NSInteger {
   UIBarMetricsDefault,
   UIBarMetricsLandscapePhone,
   UIBarMetricsDefaultPrompt = 101, // Applicable only in bars with the prompt
   // property,
   such as UINavigationBar and UISearchBar
   UIBarMetricsLandscapePhonePrompt,
} UIBarMetrics;
Constants
UIBarMetricsDefault

Specifies default metrics for the device.

Available in iOS 5.0 and later.

Declared in UIBarCommon.h.

UIBarMetricsLandscapePhone

Specifies metrics for landscape orientation using the phone idiom.

Available in iOS 5.0 and later.

Declared in UIBarCommon.h.

UIBarMetricsDefaultPrompt

Specifies default metrics for the device for bars with the prompt property, such as UINavigationBar and UISearchBar.

Available in iOS 7.0 and later.

Declared in UIBarCommon.h.

UIBarMetricsLandscapePhonePrompt

Specifies metrics for landscape orientation using the phone idiom for bars with the prompt property, such as UINavigationBar and UISearchBar.

Available in iOS 7.0 and later.

Declared in UIBarCommon.h.

UIBarPosition

Constants to identify the position of a bar.

typedef enum: NSInteger {
   UIBarPositionAny = 0,
   UIBarPositionBottom = 1,
   UIBarPositionTop = 2,
   UIBarPositionTopAttached = 3,
} UIBarPosition;
Constants
UIBarPositionAny

Specifies that the position is unspecified.

Available in iOS 7.0 and later.

Declared in UIBarCommon.h.

UIBarPositionBottom

Specifies that the bar is at the bottom of its containing view.

The system uses this as a hint to draw directional decoration accordingly. For example, any shadow would be drawn above the bar.

Available in iOS 7.0 and later.

Declared in UIBarCommon.h.

UIBarPositionTop

Specifies that the bar is at the top of its containing view.

The system uses this as a hint to draw directional decoration accordingly. For example, any shadow would be drawn below the bar.

Instances of UIToolbar do not appear with this position on iPhone, but they can on iPad.

Available in iOS 7.0 and later.

Declared in UIBarCommon.h.

UIBarPositionTopAttached

Specifies that the bar is at the top of the screen, as well as its containing view.

Bars with this position draw their background extended upwards, allowing their background content to show through the status bar.

Available in iOS 7.0 and later.

Declared in UIBarCommon.h.