iOS Developer Library

Developer

UIKit Framework Reference UIBarPositioningDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

UIBarPositioningDelegate

The UIBarPositioningDelegate protocol supports the positioning of a bar that conforms to the UIBarPositioning protocol. Navigation bars, toolbars, and search bars all have delegates that support this protocol. The delegate can use the method of this protocol to specify the bar’s position when that bar is moved to a window.

The UINavigationBarDelegate, UISearchBarDelegate, and UIToolbarDelegate protocols extend this protocol to allow for the positioning of those bars on the screen.

Inheritance


Not Applicable

Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 7.0 and later.
  • Asks the delegate for the position of the specified bar in its new window. (required)

    Declaration

    Swift

    optional func positionForBar(_ bar: UIBarPositioning) -> UIBarPosition

    Objective-C

    - (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar

    Parameters

    bar

    The bar that was added to the window.

    Return Value

    The position of the bar.

    Discussion

    If your interface has a custom bar with a delegate, that delegate can implement this method and use it to specify the position of the bar that has been added to a window.

    Delegates for the UINavigationBar and UISearchBar classes return the value UIBarPositionTop by default. The delegate of the UIToolbar class returns the value UIBarPositionBottom by default.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.