PSPDFAnnotationToolbar

Objective-C


@interface PSPDFAnnotationToolbar
    : PSPDFFlexibleToolbar <PSPDFAnnotationStateManagerDelegate,
                            PSPDFOverridable>

Swift

class AnnotationToolbar : FlexibleToolbar, AnnotationStateManagerDelegate, Overridable

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

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

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

Since the annotation toolbar works with UIButton directly (rather than using UIBarButtonItem), the buttons in it can’t be added directly to the main toolbar or navigation bar. This must be achieved by adding a custom item to the navigationItems or toolbarItems that sets the state of the PSPDFAnnotationStateManager.

Note

Directly updating buttons will not work. Use additionalButtons if you want to add custom buttons.
  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_DEFAULT_VIEW_INIT_UNAVAILABLE
  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_DEFAULT_VIEW_INIT_UNAVAILABLE
  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_DEFAULT_VIEW_INIT_UNAVAILABLE
  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_DEFAULT_VIEW_INIT_UNAVAILABLE
  • The designated initializer, which sets up the toolbar with an annotation state manager.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithAnnotationStateManager:
        (nonnull PSPDFAnnotationStateManager *)annotationStateManager;

    Swift

    init(annotationStateManager: AnnotationStateManager)
  • The attached annotation state manager, which holds the state of the currently selected tool.

    Declaration

    Objective-C

    @property (nonatomic) PSPDFAnnotationStateManager *_Nonnull annotationStateManager;

    Swift

    var annotationStateManager: AnnotationStateManager { get set }
  • The annotation types that may be shown in the annotation toolbar. In the default state, and if set to nil, this will return pdfController.configuration.editableAnnotationTypes.

    Declaration

    Objective-C

    @property (nonatomic, copy, null_resettable) NSSet<PSPDFAnnotationString> *editableAnnotationTypes;

    Swift

    var editableAnnotationTypes: Set<Annotation.Tool>! { get set }
  • 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 (nonatomic, copy, 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 (nonatomic, readonly) NSArray<__kindof PSPDFAnnotationGroup *> *_Nonnull annotationGroups;

    Swift

    var annotationGroups: [PSPDFAnnotationGroup] { get }
  • Access to buttons created based on the state of annotationGroups.

    Declaration

    Objective-C

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

    Swift

    func button(withType type: Annotation.Tool, variant: Annotation.Variant?, createFromGroup: Bool) -> UIButton?

    Parameters

    type

    The type of the annotation tool.

    variant

    The variant of the annotation tool. Can be nil if the tool has no variants.

    createFromGroup

    If this is set to true, the toolbar will automatically update and display the queried button, in case it was previously not the chosen item in the corresponding annotation group and the annotation state manager doesn’t specify a different active state in the same group. Be sure to set this to false to avoid the method from causing those side-effects.

  • 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 (nonatomic, copy, nullable) NSArray<__kindof UIButton *> *additionalButtons;

    Swift

    var additionalButtons: [UIButton]? { get set }
  • Collapses the undo and redo buttons into one button for smaller toolbar sizes. Defaults to true.

    Note

    This currently just hides the redo button.

    Declaration

    Objective-C

    @property (nonatomic) BOOL collapseUndoButtonsForCompactSizes;

    Swift

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

    Declaration

    Objective-C

    @property (nonatomic) BOOL showsApplePencilButtonAutomatically;

    Swift

    var showsApplePencilButtonAutomatically: Bool { get set }
  • Whether applePencilButton is shown in the annotation toolbar.

    The initial value of this property will be true if an Apple Pencil has been detected, or false if not.

    This property will be changed by PSPDFKit when detecting an Apple Pencil if showsApplePencilButtonAutomatically is true.

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

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite,
              getter=isShowingApplePencilButton) BOOL showingApplePencilButton;

    Swift

    var isShowingApplePencilButton: Bool { get set }
  • Animated setter for showingApplePencilButton.

    Declaration

    Objective-C

    - (void)setShowingApplePencilButton:(BOOL)showingApplePencilButton
                               animated:(BOOL)animated;

    Swift

    func setShowingApplePencilButton(_ showingApplePencilButton: 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 false.

    Declaration

    Objective-C

    @property (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 (nonatomic, readonly, nullable) UIButton *doneButton;

    Swift

    var doneButton: UIButton? { get }
  • Shows whether Apple Pencil is being used to interact with annotations.

    Tapping this button shows PSPDFApplePencilController which lets the user enable or disable Apple Pencil.

    Declaration

    Objective-C

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

    Swift

    var applePencilButton: PSPDFToolbarButton? { get }
  • Undoes 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 (nonatomic, readonly, nullable) UIButton *undoButton;

    Swift

    var undoButton: UIButton? { get }
  • Redoes 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 (nonatomic, readonly, nullable) UIButton *redoButton;

    Swift

    var redoButton: UIButton? { get }
  • 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 (nonatomic, readonly, 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 (nonatomic, readonly, nullable) PSPDFColorButton *strokeColorButton;

    Swift

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

    Declaration

    Objective-C

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

    Swift

    func done(_ sender: Any?)