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 (nonatomic, strong) 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 (nonatomic, copy, 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
itemsAn array of custom bar button items to display on the left side of the navigation bar.
animatedSpecify
YESto animate the transition to the custom bar items when this item is the top item. SpecifyNOto set the items immediately without animating the change. -
Returns the
leftBarButtonItemsfor the given horizontal user interface size class.Declaration
Objective-C
- (nullable NSArray<UIBarButtonItem *> *)leftBarButtonItemsForSizeClass: (UIUserInterfaceSizeClass)sizeClass;Swift
func leftBarButtonItems(for sizeClass: UIUserInterfaceSizeClass) -> [UIBarButtonItem]?Parameters
sizeClassthe horizontal user interface size class
Return Value
the
leftBarButtonItemsfor the given horizontal user interface size class, ornilif there are no items set for the size class -
Sets the
leftBarButtonItemsused 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
leftBarButtonItemsthe list of bar button items
sizeClassthe horizontal user interface size class
animatedwhether 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 (nonatomic, strong, 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
itemA custom bar item to display on the left side of the navigation bar.
animatedSpecify
YESto animate the transition to the custom bar item when this item is the top item. SpecifyNOto set the item immediately without animating the change. -
Returns the
leftBarButtonItemfor 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
sizeClassthe horizontal user interface size class
Return Value
the
leftBarButtonItemfor the given horizontal user interface size class, ornilif there is no item set for the size class -
Sets the
leftBarButtonItemused 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 theleftBarButtonItemspecified 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
leftBarButtonItemthe bar button item
sizeClassthe horizontal user interface size class
animatedwhether 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 (nonatomic, copy, 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
itemsAn array of custom bar button items to display on the right side of the navigation bar.
animatedSpecify
YESto animate the transition to the custom bar items when this item is the top item. SpecifyNOto set the items immediately without animating the change. -
Returns the
rightBarButtonItemsfor the given horizontal user interface size class.Declaration
Objective-C
- (nullable NSArray<UIBarButtonItem *> *)rightBarButtonItemsForSizeClass: (UIUserInterfaceSizeClass)sizeClass;Swift
func rightBarButtonItems(for sizeClass: UIUserInterfaceSizeClass) -> [UIBarButtonItem]?Parameters
sizeClassthe horizontal user interface size class
Return Value
the
rightBarButtonItemsfor the given horizontal user interface size class, ornilif there are no items set for the size class -
Sets the
rightBarButtonItemsused 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
rightBarButtonItemsthe list of bar button items
sizeClassthe horizontal user interface size class
animatedwhether 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 (nonatomic, strong, 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
itemA custom bar item to display on the right of the navigation bar.
animatedSpecify
YESto animate the transition to the custom bar item when this item is the top item. SpecifyNOto set the item immediately without animating the change. -
Returns the
rightBarButtonItemfor 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
sizeClassthe horizontal user interface size class
Return Value
the
rightBarButtonItemfor the given horizontal user interface size class, ornilif there is no item set for the size class -
Sets the
rightBarButtonItemused 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 therightBarButtonItemspecified 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
rightBarButtonItemthe bar button item
sizeClassthe horizontal user interface size class
animatedwhether to animate change
PTDocumentNavigationItem Class Reference