PSPDFFlexibleToolbar
Objective-C
@interface PSPDFFlexibleToolbar : PSPDFToolbar
Swift
class FlexibleToolbar : Toolbar
A custom toolbar, that can be dragged around the screen and anchored to different positions.
This class holds an array of UIButton
objects. For best results use ToolbarButton
or one of its subclasses.
FlexibleToolbar
should be used in combination with a FlexibleToolbarContainer
instance.
The bar’s visual appearance can be customized using UIAppearance compliant properties.
-
A list of valid toolbar positions.
Defaults to
.default
on iOS,.inTopBar
on Mac Catalyst, and.vertical
on visionOS.@note: Change this before setting
toolbarPosition
, else any unsupportedtoolbarPosition
is rejected.Declaration
Objective-C
@property (nonatomic) PSPDFFlexibleToolbarPosition supportedToolbarPositions;
Swift
var supportedToolbarPositions: FlexibleToolbar.Position { get set }
-
Current toolbar position.
See
setToolbarPosition:animated:
Note
Ensure that any new toolbar position is supported in
supportedToolbarPositions
, else the value is rejected.Declaration
Objective-C
@property (nonatomic) PSPDFFlexibleToolbarPosition toolbarPosition;
Swift
var toolbarPosition: FlexibleToolbar.Position { get set }
-
Sets the toolbar position and optionally animates the change
When
PSPDFFlexibleToolbarPositionNone
is used (the default value) the toolbar can select an appropriate default position or restore position from previous runs.Note: Only set concrete positions here, and not any of the combined ones (like
.default
,.all
,.horizontal
, or.vertical
.Declaration
Objective-C
- (void)setToolbarPosition:(PSPDFFlexibleToolbarPosition)toolbarPosition animated:(BOOL)animated;
Swift
func setToolbarPosition(_ toolbarPosition: FlexibleToolbar.Position, animated: Bool)
Parameters
toolbarPosition
The new toolbar position to set. Limited to
supportedToolbarPositions
.animated
Whether the toolbar should animate into the new position (move or fade, depending on whether the orientation changes).
-
Toolbar delegate. (Can be freely set to any receiver)
Declaration
Objective-C
@property (nonatomic, weak) id<PSPDFFlexibleToolbarDelegate> _Nullable toolbarDelegate;
Swift
weak var toolbarDelegate: FlexibleToolbarDelegate? { get set }
-
Enables or disables toolbar dragging (hides the
dragView
when disabled).isDragEnabled
will return false ifsupportedToolbarPositions
has only one possible position.Defaults to true on iOS, false on Mac Catalyst and visionOS.
Declaration
Objective-C
@property (nonatomic, getter=isDragEnabled) BOOL dragEnabled;
Swift
var isDragEnabled: Bool { get set }
-
The currently selected button. The selected button is indicated by a selection bezel behind the button. The selected button’s tint color gets automatically adjusted to
selectedTintColor
as well.Declaration
Objective-C
@property (nonatomic, nullable) UIButton *selectedButton;
Swift
var selectedButton: UIButton? { get set }
-
Sets the selection button and optionally fades the selection view.
Declaration
Objective-C
- (void)setSelectedButton:(nullable UIButton *)button animated:(BOOL)animated;
Swift
func setSelectedButton(_ button: UIButton?, animated: Bool)
-
Drag indicator view, positioned on the right or bottom of the toolbar (depending on the toolbar orientation). Drag & drop gesture recognizers (UIPanGestureRecognizer) should be added to this view. Visible only if
dragEnabled
is set to YES.Declaration
Objective-C
@property (nonatomic, readonly) PSPDFFlexibleToolbarDragView *_Nonnull dragView;
Swift
var dragView: PSPDFFlexibleToolbarDragView { get }
-
The tint color for selected buttons. Defaults to
standardAppearance.backgroundColor
if available, orbarTintColor
if available, otherwise an attempt is made to select an appropriate color based on thebackgroundView
appearance.Declaration
Objective-C
@property (nonatomic) UI_APPEARANCE_SELECTOR UIColor *selectedTintColor;
Swift
var selectedTintColor: UIColor { get set }
-
The selection bezel color. Defaults to self.tintColor.
Declaration
Objective-C
@property (nonatomic) UI_APPEARANCE_SELECTOR UIColor *selectedBackgroundColor;
Swift
var selectedBackgroundColor: UIColor { get set }
-
Toolbar positions that draw a thin border around the toolbar. Defaults to
PSPDFFlexibleToolbarPositionAll
.Declaration
Objective-C
@property (nonatomic) PSPDFFlexibleToolbarPosition borderedToolbarPositions;
Swift
var borderedToolbarPositions: FlexibleToolbar.Position { get set }
-
Toolbar positions that draw a faint shadow around the toolbar. Defaults to
PSPDFFlexibleToolbarPositionVertical
.Declaration
Objective-C
@property (nonatomic) PSPDFFlexibleToolbarPosition shadowedToolbarPositions;
Swift
var shadowedToolbarPositions: FlexibleToolbar.Position { get set }
-
Toolbar positions that slightly round the background view. Defaults to
PSPDFFlexibleToolbarPositionVertical
.Declaration
Objective-C
@property (nonatomic) PSPDFFlexibleToolbarPosition roundedToolbarPositions;
Swift
var roundedToolbarPositions: FlexibleToolbar.Position { get set }
-
Matches the toolbar appearance to the provided UINavigationBar or UIToolbar. Includes
barTintColor
,tintColor
,barStyle
,translucency
,standardAppearance
andcompactAppearance
. ThebarTintColor
,tintColor
,standardAppearance
andcompactAppearance
are only matched if the haven’t been already explicitly set (using properties or UIAppearance).Declaration
Objective-C
- (void)matchUIBarAppearance: (nonnull UIView<PSPDFSystemBar> *)navigationBarOrToolbar;
Swift
func matchUIBarAppearance(_ navigationBarOrToolbar: UIView & PSPDFSystemBar)
-
Returns the toolbars native size for the provided position, bound to the
availableSize
. Internally used by the container view to correctly position the toolbar and anchor views during drag & drop. The toolbar height will be increased when docked underneath the status bar byFlexibleToolbarContainer
.See
-[PSPDFFlexibleToolbarContainer rectForToolbarPosition:]Declaration
Objective-C
- (CGSize)preferredSizeFitting:(CGSize)availableSize forToolbarPosition:(PSPDFFlexibleToolbarPosition)position;
Swift
func preferredSizeFitting(_ availableSize: CGSize, for position: FlexibleToolbar.Position) -> CGSize
-
Deprecated
Deprecated in PSPDFKit 12.3 for iOS. Use ‘UIButton.menu’ to add context menus to buttons instead.
Present a legacy menu for the given button.
Warning
This method is deprecated. Use
UIButton.menu
to add context menus to buttons instead.Declaration
Objective-C
- (void)showMenuWithItems:(nonnull NSArray<PSPDFMenuItem *> *)menuItems target:(nonnull UIView *)target animated:(BOOL)animated;
Swift
func showMenu(with menuItems: [PSPDFMenuItem], target: UIView, animated: Bool)
-
Deprecated
Deprecated in PSPDFKit 12.3 for iOS. Use ‘UIButton.menu’ to add context menus to buttons instead.
Present a legacy menu for
collapsedButton
. The default implementation usesmenuItemForButton:
to convert collapsedbuttons
into legacy menu items and then callsshowMenuWithItems:target:animated:
.Warning
This method is deprecated. Use
UIButton.menu
to add context menus to buttons instead.Declaration
Objective-C
- (void)showMenuForCollapsedButtons: (nonnull NSArray<__kindof UIButton *> *)buttons fromButton:(nonnull UIButton *)sourceButton animated:(BOOL)animated;
Swift
func showMenu(forCollapsedButtons buttons: [UIButton], from sourceButton: UIButton, animated: Bool)
-
Deprecated
Deprecated in PSPDFKit 12.3 for iOS. Use ‘UIButton.menu’ to add context menus to buttons instead.
Convert a button into a legacy menu item.
Warning
This method is deprecated. Use
UIButton.menu
to add context menus to buttons instead.Declaration
Objective-C
- (nonnull PSPDFMenuItem *)menuItemForButton:(nonnull UIButton *)button;
Swift
func menuItem(for button: UIButton) -> PSPDFMenuItem
Return Value
A legacy menu item for the given button.