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 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.
  • 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
  • Designated initializer.

    Declaration

    Objective-C

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

    Swift

    init(annotationStateManager: AnnotationStateManager)
  • Attached annotation state manager.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        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, readwrite, 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, readwrite, 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. 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 PSPDFAnnotationVariantString)variant
                         createFromGroup:(BOOL)createFromGroup;

    Swift

    func button(withType type: Annotation.Tool, variant: Annotation.Variant?, createFromGroup: Bool) -> UIButton
  • 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, readwrite, 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 YES.

    Note

    This currently just hides the redo button.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        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 (nonatomic, assign, unsafe_unretained, readwrite)
        BOOL showsApplePencilButtonAutomatically;

    Swift

    var showsApplePencilButtonAutomatically: Bool { get set }
  • Whether applePencilButton 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 showsApplePencilButtonAutomatically is YES.

    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 NO.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        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?)