PTDocumentNavigationItem


@interface PTDocumentNavigationItem : UINavigationItem

A UINavigationItem subclass that allows setting different sets of bar button items for different user interface size classes.

  • The current trait collection of the navigation item’s owning view controller. The value of this property should be updated in the -traitCollectionDidChange: method of the owning view controller.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        UITraitCollection *_Nonnull traitCollection;

    Swift

    var traitCollection: UITraitCollection { get set }
  • An array of custom bar button items to display on the left (or leading) side of the navigation bar when the receiver is the top navigation item.

    The getter for this property returns -leftBarButtonItemsForSizeClass: for the current horizontal user inteface size class, and the setter uses -setLeftBarButtonItems:forSizeClass:animated: to set the items for all user interface size classes.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable)
        NSArray<UIBarButtonItem *> *leftBarButtonItems;

    Swift

    var leftBarButtonItems: [UIBarButtonItem]? { get set }
  • Sets the left bar button items for all horizontal user interface size classes, optionally animating the transition to the new items.

    Declaration

    Objective-C

    - (void)setLeftBarButtonItems:(nullable NSArray<UIBarButtonItem *> *)items
                         animated:(BOOL)animated;

    Swift

    func setLeftBarButtonItems(_ items: [UIBarButtonItem]?, animated: Bool)

    Parameters

    items

    An array of custom bar button items to display on the left side of the navigation bar.

    animated

    Specify YES to animate the transition to the custom bar items when this item is the top item. Specify NO to set the items immediately without animating the change.

  • Returns the leftBarButtonItems for the given horizontal user interface size class.

    Declaration

    Objective-C

    - (nullable NSArray<UIBarButtonItem *> *)leftBarButtonItemsForSizeClass:
        (UIUserInterfaceSizeClass)sizeClass;

    Swift

    func leftBarButtonItems(for sizeClass: UIUserInterfaceSizeClass) -> [UIBarButtonItem]?

    Parameters

    sizeClass

    the horizontal user interface size class

    Return Value

    the leftBarButtonItems for the given horizontal user interface size class, or nil if there are no items set for the size class

  • Sets the leftBarButtonItems used for the given horizontal user interface size class.

    Declaration

    Objective-C

    - (void)setLeftBarButtonItems:
                (nullable NSArray<UIBarButtonItem *> *)leftBarButtonItems
                     forSizeClass:(UIUserInterfaceSizeClass)sizeClass
                         animated:(BOOL)animated;

    Swift

    func setLeftBarButtonItems(_ leftBarButtonItems: [UIBarButtonItem]?, for sizeClass: UIUserInterfaceSizeClass, animated: Bool)

    Parameters

    leftBarButtonItems

    the list of bar button items

    sizeClass

    the horizontal user interface size class

    animated

    whether to animate change

  • A custom bar button item displayed on the left (or leading) edge of the navigation bar when the receiver is the top navigation item.

    The getter for this property returns -leftBarButtonItemForSizeClass: for the current horizontal user inteface size class, and the setter uses -setLeftBarButtonItem:forSizeClass:animated: to set the item for all user interface size classes.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable)
        UIBarButtonItem *leftBarButtonItem;

    Swift

    var leftBarButtonItem: UIBarButtonItem? { get set }
  • Sets the custom bar button item for all horizontal user interface size classes, optionally animating the transition to the new item.

    Declaration

    Objective-C

    - (void)setLeftBarButtonItem:(nullable UIBarButtonItem *)item
                        animated:(BOOL)animated;

    Swift

    func setLeftBarButton(_ item: UIBarButtonItem?, animated: Bool)

    Parameters

    item

    A custom bar item to display on the left side of the navigation bar.

    animated

    Specify YES to animate the transition to the custom bar item when this item is the top item. Specify NO to set the item immediately without animating the change.

  • Returns the leftBarButtonItem for the given horizontal user interface size class. If the left bar button items have been set with the -setLeftBarButtonItems:forSizeClass:animated: method, then the first item from the list for the given size class will be returned.

    Declaration

    Objective-C

    - (nullable UIBarButtonItem *)leftBarButtonItemForSizeClass:
        (UIUserInterfaceSizeClass)sizeClass;

    Swift

    func leftBarButtonItem(for sizeClass: UIUserInterfaceSizeClass) -> UIBarButtonItem?

    Parameters

    sizeClass

    the horizontal user interface size class

    Return Value

    the leftBarButtonItem for the given horizontal user interface size class, or nil if there is no item set for the size class

  • Sets the leftBarButtonItem used for the given horizontal user interface size class. If the list of left bar button items has been set with the -setLeftBarButtonItems:forSizeClass:animated: method, the list for the given size class will be overridden with the leftBarButtonItem specified here.

    Declaration

    Objective-C

    - (void)setLeftBarButtonItem:(nullable UIBarButtonItem *)leftBarButtonItem
                    forSizeClass:(UIUserInterfaceSizeClass)sizeClass
                        animated:(BOOL)animated;

    Swift

    func setLeftBarButton(_ leftBarButtonItem: UIBarButtonItem?, for sizeClass: UIUserInterfaceSizeClass, animated: Bool)

    Parameters

    leftBarButtonItem

    the bar button item

    sizeClass

    the horizontal user interface size class

    animated

    whether to animate change

  • An array of custom bar button items to display on the right (or trailing) side of the navigation bar when the receiver is the top navigation item.

    The getter for this property returns -rightBarButtonItemsForSizeClass: for the current horizontal user inteface size class, and the setter uses -setRightBarButtonItems:forSizeClass:animated: to set the items for all user interface size classes.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable)
        NSArray<UIBarButtonItem *> *rightBarButtonItems;

    Swift

    var rightBarButtonItems: [UIBarButtonItem]? { get set }
  • Sets the right bar button items for all horizontal user interface size classes, optionally animating the transition to the new items.

    Declaration

    Objective-C

    - (void)setRightBarButtonItems:(nullable NSArray<UIBarButtonItem *> *)items
                          animated:(BOOL)animated;

    Swift

    func setRightBarButtonItems(_ items: [UIBarButtonItem]?, animated: Bool)

    Parameters

    items

    An array of custom bar button items to display on the right side of the navigation bar.

    animated

    Specify YES to animate the transition to the custom bar items when this item is the top item. Specify NO to set the items immediately without animating the change.

  • Returns the rightBarButtonItems for the given horizontal user interface size class.

    Declaration

    Objective-C

    - (nullable NSArray<UIBarButtonItem *> *)rightBarButtonItemsForSizeClass:
        (UIUserInterfaceSizeClass)sizeClass;

    Swift

    func rightBarButtonItems(for sizeClass: UIUserInterfaceSizeClass) -> [UIBarButtonItem]?

    Parameters

    sizeClass

    the horizontal user interface size class

    Return Value

    the rightBarButtonItems for the given horizontal user interface size class, or nil if there are no items set for the size class

  • Sets the rightBarButtonItems used for the given horizontal user interface size class.

    Declaration

    Objective-C

    - (void)setRightBarButtonItems:
                (nullable NSArray<UIBarButtonItem *> *)rightBarButtonItems
                      forSizeClass:(UIUserInterfaceSizeClass)sizeClass
                          animated:(BOOL)animated;

    Swift

    func setRightBarButtonItems(_ rightBarButtonItems: [UIBarButtonItem]?, for sizeClass: UIUserInterfaceSizeClass, animated: Bool)

    Parameters

    rightBarButtonItems

    the list of bar button items

    sizeClass

    the horizontal user interface size class

    animated

    whether to animate change

  • A custom bar button item displayed on the right (or trailing) edge of the navigation bar when the receiver is the top navigation item.

    The getter for this property returns -rightBarButtonItemForSizeClass: for the current horizontal user inteface size class, and the setter uses -setRightBarButtonItem:forSizeClass:animated: to set the item for all user interface size classes.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable)
        UIBarButtonItem *rightBarButtonItem;

    Swift

    var rightBarButtonItem: UIBarButtonItem? { get set }
  • Sets the custom bar button item for all horizontal user interface size classes, optionally animating the transition to the view.

    Declaration

    Objective-C

    - (void)setRightBarButtonItem:(nullable UIBarButtonItem *)item
                         animated:(BOOL)animated;

    Swift

    func setRightBarButton(_ item: UIBarButtonItem?, animated: Bool)

    Parameters

    item

    A custom bar item to display on the right of the navigation bar.

    animated

    Specify YES to animate the transition to the custom bar item when this item is the top item. Specify NO to set the item immediately without animating the change.

  • Returns the rightBarButtonItem for the given horizontal user interface size class. If the right bar button items have been set with the -setRightBarButtonItems:forSizeClass:animated: method, then the first item from the list for the given size class will be returned.

    Declaration

    Objective-C

    - (nullable UIBarButtonItem *)rightBarButtonItemForSizeClass:
        (UIUserInterfaceSizeClass)sizeClass;

    Swift

    func rightBarButtonItem(for sizeClass: UIUserInterfaceSizeClass) -> UIBarButtonItem?

    Parameters

    sizeClass

    the horizontal user interface size class

    Return Value

    the rightBarButtonItem for the given horizontal user interface size class, or nil if there is no item set for the size class

  • Sets the rightBarButtonItem used for the given horizontal user interface size class. If the list of right bar button items has been set with the -setRightBarButtonItems:forSizeClass:animated: method, the list for the given size class will be overridden with the rightBarButtonItem specified here.

    Declaration

    Objective-C

    - (void)setRightBarButtonItem:(nullable UIBarButtonItem *)rightBarButtonItem
                     forSizeClass:(UIUserInterfaceSizeClass)sizeClass
                         animated:(BOOL)animated;

    Swift

    func setRightBarButton(_ rightBarButtonItem: UIBarButtonItem?, for sizeClass: UIUserInterfaceSizeClass, animated: Bool)

    Parameters

    rightBarButtonItem

    the bar button item

    sizeClass

    the horizontal user interface size class

    animated

    whether to animate change