iOS Developer Library

Developer

UIBarPositioning Protocol Reference

Options
Deployment Target:

On This Page
Language:

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. More...

Inheritance


Not Applicable

Import Statement


import UIKit @import UIKit;

Availability


Available in iOS 7.0 and later.
  • barPosition barPosition Required Property

    The position of the bar. (required)

    Declaration

    Swift

    var barPosition: UIBarPosition { get }

    Objective-C

    @property(nonatomic, readonly) UIBarPosition barPosition

    Import Statement

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • Constants to specify metrics to use for appearance.

    Declaration

    Swift

    enum UIBarMetrics : Int { case Default case Compact case DefaultPrompt case CompactPrompt }

    Objective-C

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

    Constants

    • Default

      UIBarMetricsDefault

      Specifies default metrics for the device.

      Available in iOS 5.0 and later.

    • UIBarMetricsLandscapePhone

      UIBarMetricsLandscapePhone

      Specifies metrics for landscape orientation using the phone idiom.

      Available in iOS 5.0 and later.

      Deprecated in iOS 8.0.

    • DefaultPrompt

      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.

    • UIBarMetricsLandscapePhonePrompt

      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.

      Deprecated in iOS 8.0.

    Import Statement

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • Constants to identify the position of a bar.

    Declaration

    Swift

    enum UIBarPosition : Int { case Any case Bottom case Top case TopAttached }

    Objective-C

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

    Constants

    • Any

      UIBarPositionAny

      Specifies that the position is unspecified.

      Available in iOS 7.0 and later.

    • Bottom

      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.

    • Top

      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.

    • TopAttached

      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.

    Import Statement

    import UIKit

    Availability

    Available in iOS 7.0 and later.