PSPDFAnnotationToolbar


@interface PSPDFAnnotationToolbar
    : PSPDFFlexibleToolbar <PSPDFAnnotationStateManagerDelegate>

The annotation toolbar allows the creation of most annotation types supported by PSPDFKit.

To customize which annotation icons should be displayed, edit editableAnnotationTypes in PSPDFDocument. Further appearance customization options are documented in the superclass header (PSPDFFlexibleToolbar.h).

PSPDFAnnotationToolbar needs to be used together with a PSPDFFlexibleToolbarContainerView just like its superclass PSPDFFlexibleToolbar.

Note

Directly updating buttons will not work. Use additionalButtons if you want to add custom buttons.
  • Specifies a list of toolbar configurations amongst which the toolbar can pick when laying out items. The toolbar automatically picks an appropriate configuration based on the available space. Items are grouped by default. Set to nil to disable grouping. In that case the toolbar will be populated by ungrouped items based based on editableAnnotationTypes. - note: Annotation types that are present in a toolbar configuration but missing in editableAnnotationTypes will be not be shown.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable)
        NSArray<PSPDFAnnotationToolbarConfiguration *> *configurations;

    Swift

    var configurations: [PSPDFAnnotationToolbarConfiguration]? { get set }
  • Returns annotationGroups based on the selected configuration if set, or implicitly created groups based on editableAnnotationTypes.

    Declaration

    Objective-C

    @property (readonly, nonatomic)
        NSArray<__kindof PSPDFAnnotationGroup *> *_Nonnull annotationGroups;

    Swift

    var annotationGroups: [PSPDFAnnotationGroup] { get }
  • Access to buttons created based on the state of annotationGroups. If createFromGroup is set to YES, the toolbar will automatically update and display the queried button, in case it was previously not the chosen item in the corresponding annotation group.

    Declaration

    Objective-C

    - (nonnull UIButton *)buttonWithType:(nonnull PSPDFAnnotationString)type
                                 variant:(nullable PSPDFAnnotationString)variant
                         createFromGroup:(BOOL)createFromGroup;

    Swift

    func button(withType type: PSPDFAnnotationString, variant: PSPDFAnnotationString?, createFromGroup: Bool) -> Any!
  • Allows custom UIButton objects to be added after the buttons in annotationGroups. For best results use PSPDFToolbarButton objects. Defaults to nil. - note: The buttons should have unique accessibility labels so we can show them in a menu if needed.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable)
        NSArray<__kindof UIButton *> *additionalButtons;

    Swift

    var additionalButtons: [Any]? { get set }
  • Collapses the undo and redo buttons into one button for smaller toolbar sizes. Defaults to YES. - note: This currently just hides the redo button.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL collapseUndoButtonsForCompactSizes;

    Swift

    var collapseUndoButtonsForCompactSizes: Bool { get set }
  • Whether showingStylusButton should be set to YES if an Apple Pencil is detected. Set this to NO if you don’t want the annotation toolbar to show this button, or want to decide when to show it yourself. Defaults to YES.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL showsStylusButtonAutomatically;

    Swift

    var showsStylusButtonAutomatically: Bool { get set }
  • Whether stylusButton is shown in the annotation toolbar. The initial value of this property will be YES if an Apple Pencil has been detected, or NO if not. This property will be changed by PSPDFKit when detecting an Apple Pencil if showsStylusButtonAutomatically is YES.

    It is recommended to only set this to YES only if supporting third-party styli or if your app detects Apple Pencil touches itself, otherwise the button will be shown even though it isn’t possible to connect a stylus.

    Calling the setter of this property does not animate the change. To animate, use setShowingStylusButton:animated:.

    Declaration

    Objective-C

    @property (getter=isShowingStylusButton, assign, readwrite, nonatomic)
        BOOL showingStylusButton;

    Swift

    var isShowingStylusButton: Bool { get set }
  • Animated setter for showingStylusButton.

    Declaration

    Objective-C

    - (void)setShowingStylusButton:(BOOL)showingStylusButton
                          animated:(BOOL)animated;

    Swift

    func setShowingStylusButton(_ showingStylusButton: Bool, animated: Bool)
  • This will issue a save event after the toolbar has been dismissed. - note: Since saving can take some time, this defaults to NO.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL saveAfterToolbarHiding;

    Swift

    var saveAfterToolbarHiding: Bool { get set }
  • Dismisses the annotation toolbar. - note: Not nil by default, but can be overridden to return nil to remove it from the toolbar.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) UIButton *doneButton;

    Swift

    var doneButton: UnsafeMutablePointer
  • Shows whether a stylus is being used. This includes Apple Pencil and vendor styli. Tapping this button shows PSPDFStylusViewController which lets the user change the stylus being used or stop using a stylus.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) PSPDFToolbarButton *stylusButton;

    Swift

    var stylusButton: PSPDFToolbarButton? { get }
  • Undos the last action. - note: Not nil by default, but can be overridden to return nil to remove it from the toolbar.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) UIButton *undoButton;

    Swift

    var undoButton: UnsafeMutablePointer
  • Redos the last action. - note: Not nil by default, but can be overridden to return nil to remove it from the toolbar.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) UIButton *redoButton;

    Swift

    var redoButton: UnsafeMutablePointer
  • Shows a menu with undo / redo options. Used in compact sizes instead of undoButton and redoButton. - note: Not nil by default, but can be overridden to return nil to remove it from the toolbar.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) PSPDFToolbarDualButton *undoRedoButton;

    Swift

    var undoRedoButton: PSPDFToolbarDualButton? { get }
  • Shows the annotation inspector for the selected annotation type. Hidden (but not removed), if a relevant type is currently not selected. Only added to the toolbar, if the toolbar contains buttons for supported annotation types. - note: Not nil by default, but can be override to return nil to remove it from the toolbar.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) PSPDFColorButton *strokeColorButton;

    Swift

    var strokeColorButton: PSPDFColorButton? { get }
  • The done action.

    Declaration

    Objective-C

    - (void)done:(nullable id)sender;

    Swift

    func done(_ sender: Any?)