iOS Developer Library

Developer

UIBarPositioning Protocol Reference

Options
Deployment Target:

On This Page

UIBarPositioning

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.

  • Constants to specify metrics to use for appearance.

    Declaration

    typedef enum : NSInteger { UIBarMetricsDefault, UIBarMetricsCompact, UIBarMetricsDefaultPrompt = 101, UIBarMetricsCompactPrompt, UIBarMetricsLandscapePhone , // Deprecated UIBarMetricsLandscapePhonePrompt , // Deprecated. } UIBarMetrics;

    Constants

    • UIBarMetricsDefault

      Specifies default metrics for the device.

    • UIBarMetricsCompact

      Specifies metrics when using the phone idiom.

    • UIBarMetricsDefaultPrompt

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

    • UIBarMetricsCompactPrompt

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

    • UIBarMetricsLandscapePhone

      Specifies metrics for landscape orientation using the phone idiom.

      Use UIBarMetricsCompact instead.

    • UIBarMetricsLandscapePhonePrompt

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

      Use UIBarMetricsCompactPrompt instead.

  • Constants to identify the position of a bar.

    Declaration

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

    Constants

    • UIBarPositionAny

      Specifies that the position is unspecified.

    • UIBarPositionBottom

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

    • UIBarPositionTop

      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.

    • UIBarPositionTopAttached

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