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 PSPDFToolbarButton or one of its subclasses. PSPDFFlexibleToolbar should be used in combination with a PSPDFFlexibleToolbarContainer instance. The bar’s visual appearance can be customized using UIAppearance compliant properties.

  • A list of valid toolbar positions.

    Defaults to PSPDFFlexibleToolbarPositionDefault on iOS and PSPDFFlexibleToolbarPositionInTopBar on Mac Catalyst.

    @note: Change this before setting toolbarPosition, else any unsupported toolbarPosition 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.

    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 NO if supportedToolbarPositions has only one possible position.

    Defaults to YES on iOS and NO on Mac Catalyst.

    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)
  • Shows the toolbar (optionally by fading it in).

    Declaration

    Objective-C

    - (void)showToolbarAnimated:(BOOL)animated
                     completion:(nullable void (^)(BOOL))completionBlock;

    Swift

    func show(animated: Bool) async -> Bool
  • Hides the toolbar (optionally by fading it out).

    Declaration

    Objective-C

    - (void)hideToolbarAnimated:(BOOL)animated
                     completion:(nullable void (^)(BOOL))completionBlock;

    Swift

    func hide(animated: Bool) async -> 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, or barTintColor if available, otherwise an attempt is made to select an appropriate color based on the backgroundView 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 and compactAppearance. The barTintColor, tintColor, standardAppearance and compactAppearance are only matched if the haven’t been already explicitly set (using properties or UIAppearance).

    Declaration

    Objective-C

    - (void)matchUIBarAppearance:
        (nonnull UIView<PSPDFSystemBar> *)navigationBarOrToolbar;
  • 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 by PSPDFFlexibleToolbarContainer.

    See

    -[PSPDFFlexibleToolbarContainer rectForToolbarPosition:]

    Declaration

    Objective-C

    - (CGSize)preferredSizeFitting:(CGSize)availableSize
                forToolbarPosition:(PSPDFFlexibleToolbarPosition)position;

    Swift

    func preferredSizeFitting(_ availableSize: CGSize, for position: FlexibleToolbar.Position) -> CGSize
  • Shows a menu (UIMenuController) for a specific button.

    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)

    Parameters

    menuItems

    An array of PSPDFMenuItem objects.

    target

    The target view (most commonly on of the buttons) used to anchor the menu arrow.

    animated

    Whether to animate the menu presentation or not.

  • Called when the collapsedButton menu action is invoked. The default implementation uses menuItemForButton: to convert buttons into menu items and than calls through to showMenuWithItems:target:animated:.

    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)
  • Converts buttons into similarly styled menu items

    Declaration

    Objective-C

    - (nonnull PSPDFMenuItem *)menuItemForButton:(nonnull UIButton *)button;

    Swift

    func menuItem(for button: UIButton) -> PSPDFMenuItem