PSPDFFlexibleToolbar


@interface PSPDFFlexibleToolbar : PSPDFToolbar

A custom toolbar, that can 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 PSPDFFlexibleToolbarPositionsAll.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        PSPDFFlexibleToolbarPosition supportedToolbarPositions;

    Swift

    var supportedToolbarPositions: PSPDFFlexibleToolbarPosition { get set }
  • Current toolbar position (limited to supportedToolbarPositions).

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        PSPDFFlexibleToolbarPosition toolbarPosition;

    Swift

    var toolbarPosition: PSPDFFlexibleToolbarPosition { get set }
  • Sets the toolbar position and optionally animates the change (move or fade, depending on whether the orientation changes)

    Declaration

    Objective-C

    - (void)setToolbarPosition:(PSPDFFlexibleToolbarPosition)toolbarPosition
                      animated:(BOOL)animated;

    Swift

    func setToolbarPosition(_ toolbarPosition: PSPDFFlexibleToolbarPosition, animated: Bool)
  • Toolbar delegate. (Can be freely set to any receiver)

    Declaration

    Objective-C

    @property (readwrite, nonatomic)
        id<PSPDFFlexibleToolbarDelegate> _Nullable toolbarDelegate;

    Swift

    weak var toolbarDelegate: PSPDFFlexibleToolbarDelegate? { get set }
  • Enables or disables toolbar dragging (hides the dragView when disabled). Defaults to YES.

    Declaration

    Objective-C

    @property (getter=isDragEnabled, assign, readwrite, nonatomic) 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 (assign, readwrite, nonatomic, nullable) UIButton *selectedButton;

    Swift

    var selectedButton: NSButton? { 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: Any!, 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, completion completionBlock: ((Bool) -> Void)? = nil)
  • 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, completion completionBlock: ((Bool) -> Void)? = nil)
  • 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 (readonly, nonatomic) PSPDFFlexibleToolbarDragView *_Nonnull dragView;

    Swift

    var dragView: PSPDFFlexibleToolbarDragView { get }
  • The tint color for selected buttons. Defaults to barTintColor if available, otherwise an attempt is made to select an appropriate color based on the backgroundView appearance.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) UIColor *_Nonnull selectedTintColor;

    Swift

    var selectedTintColor: NSColor { get set }
  • The selection bezel color. Defaults to self.tintColor.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        UIColor *_Nonnull selectedBackgroundColor;

    Swift

    var selectedBackgroundColor: NSColor { get set }
  • Toolbar positions that draw a thin border around the toolbar. Defaults to PSPDFFlexibleToolbarPositionsAll.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        PSPDFFlexibleToolbarPosition borderedToolbarPositions;

    Swift

    var borderedToolbarPositions: PSPDFFlexibleToolbarPosition { get set }
  • Toolbar positions that draw a faint shadow around the toolbar. Defaults to PSPDFFlexibleToolbarPositionsVertical.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        PSPDFFlexibleToolbarPosition shadowedToolbarPositions;

    Swift

    var shadowedToolbarPositions: PSPDFFlexibleToolbarPosition { get set }
  • Matches the toolbar appearance to the provided UINavigationBar or UIToolbar. Includes barTintColor, tintColor, barStyle and translucency. The barTintColor and tintColor 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: Any!)
  • 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: PSPDFFlexibleToolbarPosition) -> CGSize
  • Shows a menu (UIMenuController) for a specific button. - parameter: menuItems An array of PSPDFMenuItem objects. - parameter: target The target view (most commonly on of the buttons) used to anchor the menu arrow. - parameter: animated Whether to animate the menu presentation or not.

    Declaration

    Objective-C

    - (void)showMenuWithItems:(nonnull NSArray<PSPDFMenuItem *> *)menuItems
                       target:(nonnull UIView *)target
                     animated:(BOOL)animated;

    Swift

    func showMenu(with menuItems: [PSPDFMenuItem], target: Any!, 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: [NSButton], fromButton sourceButton: Any!, animated: Bool)
  • Converts buttons into similarly styled menu items

    Declaration

    Objective-C

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

    Swift

    func menuItem(forButton button: Any!) -> PSPDFMenuItem