PSPDFAnnotationStateManager


@interface PSPDFAnnotationStateManager : NSObject <PSPDFOverridable>

PSPDFAnnotationStateManager holds the current annotation state and configures the associated PSPDFViewController to accept input related to the currently selected annotation state. The class also provides several convenience methods and user interface components required for annotation creation and configuration.

Interested parties can use KVO to observe the manager’s properties.

You should never use more than one PSPDFAnnotationStateManager for any given PSPDFViewController. It’s recommended to use -[PSPDFViewController annotationStateManager] instead of creating your own one in order to make sure this requirement is always met.

PSPDFAnnotationStateManager is internally used by PSPDFAnnotationToolbar and can be re-used for any custom annotation related user interfaces.

Note

Do not create this class yourself. Use the existing class that is exposed in the PSPDFViewController.
  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFAnnotationStateManager : NSObject <PSPDFOverridable>
  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFAnnotationStateManager : NSObject <PSPDFOverridable>
  • Attached pdf controller.

    Declaration

    Objective-C

    @property (readonly, nonatomic) PSPDFViewController *_Nullable pdfController;

    Swift

    weak var pdfController: PSPDFViewController? { get }
  • Adds an annotation state delegate to the subscriber list. - note: Delegates are weakly retained, but be a good citizen and manually deregister.

    Declaration

    Objective-C

    - (void)addDelegate:(nonnull id<PSPDFAnnotationStateManagerDelegate>)delegate;

    Swift

    func add(_ delegate: PSPDFAnnotationStateManagerDelegate)
  • Removes an annotation state delegate from the subscriber list.

    Declaration

    Objective-C

    - (BOOL)removeDelegate:
        (nonnull id<PSPDFAnnotationStateManagerDelegate>)delegate;

    Swift

    func remove(_ delegate: PSPDFAnnotationStateManagerDelegate) -> Bool
  • Active annotation state. - note: Setting a state will temporarily disable the long press gesture recognizer on the PSPDFScrollView to disable the new annotation menu. Setting the state on it’s own resets the variant to nil.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) PSPDFAnnotationString state;

    Swift

    var state: PSPDFAnnotationString? { get set }
  • Sets the state to the specified annotation type, if it differs from the currently set state, otherwise sets the state to nil. - note: This will load the previous used color into drawColor and set all other options like lineWidth. Set these value AFTER setting the state if you want to customize them, or set the default in PSPDFStyleManager

    Declaration

    Objective-C

    - (void)toggleState:(nonnull PSPDFAnnotationString)state;

    Swift

    func toggleState(_ state: PSPDFAnnotationString)
  • Sets the annotation variant for the current state. States with different variants uniquely preserve the annotation style settings. This is handy for defining multiple tools of the same annotation type, each with different style settings.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) PSPDFAnnotationString variant;

    Swift

    var variant: PSPDFAnnotationString? { get set }
  • Sets the annotation type and variant at the same time. - see: state, variant

    Declaration

    Objective-C

    - (void)setState:(nullable PSPDFAnnotationString)state
             variant:(nullable PSPDFAnnotationString)variant;

    Swift

    func setState(_ state: PSPDFAnnotationString?, variant: PSPDFAnnotationString?)
  • Toggles the annotation type and variant at the same time. If the state and variant both match the currently set values, it sets both to nil. Convenient for selectable toolbar buttons.

    Declaration

    Objective-C

    - (void)toggleState:(nullable PSPDFAnnotationString)state
                variant:(nullable PSPDFAnnotationString)variant;

    Swift

    func toggleState(_ state: PSPDFAnnotationString?, variant: PSPDFAnnotationString?)
  • String identifier used as the persistence key for the current combination of state and variant.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic)
        PSPDFAnnotationString _Nonnull stateVariantIdentifier;

    Swift

    var stateVariantIdentifier: PSPDFAnnotationString { get }
  • Input mode (draw or erase) for PSPDFDrawView instances. Defaults to PSPDFDrawViewInputModeDraw.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) PSPDFDrawViewInputMode drawingInputMode;

    Swift

    var drawingInputMode: PSPDFDrawViewInputMode { get set }
  • Whether compatible annotations types may be created only with touches of type UITouchTypeStylus. If set to stylus and a compatible annotation tool is selected, users can annotate with Apple Pencil while taping and scrolling as normal with finger touches. If set to direct then single finger touches will create annotations and two fingers must be used to scroll. The default is fromStylusManager, which effectivly uses one of the other two modes depending on if the global PSPDFStylusManager is using the Apple Pencil.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        PSPDFAnnotationStateManagerStylusMode stylusMode;

    Swift

    var stylusMode: PSPDFAnnotationStateManagerStylusMode { get set }
  • Default/current drawing color. KVO observable. Defaults to [UIColor colorWithRed:0.121f green:0.35f blue:1.f alpha:1.f] - note: PSPDFKit will save the last used drawing color in NSUserDefaults. If you want to change the default value, use -[PSPDFAnnotationStyleManager setLastUsedValue:forProperty:forKey:].

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, nullable) UIColor *drawColor;

    Swift

    var drawColor: NSColor? { get set }
  • Default/current fill color. KVO observable. Defaults to nil. - note: PSPDFKit will save the last used fill color in NSUserDefaults. If you want to change the default value, use -[PSPDFAnnotationStyleManager setLastUsedValue:forProperty:forKey:].

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, nullable) UIColor *fillColor;

    Swift

    var fillColor: NSColor? { get set }
  • Current drawing line width. Defaults to 3.f. KVO observable. - note: PSPDFKit will save the last used line width in NSUserDefaults. If you want to change the default value, use -[PSPDFAnnotationStyleManager setLastUsedValue:forProperty:forKey:].

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat lineWidth;

    Swift

    var lineWidth: CGFloat { get set }
  • Starting line end type for lines and polylines. KVO observable. - note: PSPDFKit will save the last used line end in NSUserDefaults. If you want to change the default value, use -[PSPDFAnnotationStyleManager setLastUsedValue:forProperty:forKey:].

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) PSPDFLineEndType lineEnd1;

    Swift

    var lineEnd1: PSPDFLineEndType { get set }
  • Ending line end type for lines and polylines. KVO observable. - note: PSPDFKit will save the last used line end in NSUserDefaults. If you want to change the default value, use -[PSPDFAnnotationStyleManager setLastUsedValue:forProperty:forKey:].

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) PSPDFLineEndType lineEnd2;

    Swift

    var lineEnd2: PSPDFLineEndType { get set }
  • The stroke dash pattern. Draws a solid line when nil (default).

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSArray<NSNumber *> *dashArray;

    Swift

    var dashArray: [NSNumber]? { get set }
  • The border effect style.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        PSPDFAnnotationBorderEffect borderEffect;

    Swift

    var borderEffect: PSPDFAnnotationBorderEffect { get set }
  • The border effect intensity (if set to cloudy)

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat borderEffectIntensity;

    Swift

    var borderEffectIntensity: CGFloat { get set }
  • Font name for free text annotations. KVO observable. - note: PSPDFKit will save the last used font name in NSUserDefaults. If you want to change the default value, use -[PSPDFAnnotationStyleManager setLastUsedValue:forProperty:forKey:].

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *fontName;

    Swift

    var fontName: String? { get set }
  • Font size for free text annotations. KVO observable. - note: PSPDFKit will save the last used font size in NSUserDefaults. If you want to change the default value, use -[PSPDFAnnotationStyleManager setLastUsedValue:forProperty:forKey:].

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat fontSize;

    Swift

    var fontSize: CGFloat { get set }
  • Text alignment for free text annotations. KVO observable. - note: PSPDFKit will save the last used text alignment in NSUserDefaults. If you want to change the default value, use -[PSPDFAnnotationStyleManager setLastUsedValue:forProperty:forKey:].

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) NSTextAlignment textAlignment;

    Swift

    var textAlignment: NSTextAlignment { get set }
  • Shows the style picker for the current annotation class and configures it with annotation state manager style attributes. - parameter: sender A UIView or UIBarButtonItem used as the anchor view for the popover controller (iPad only). - parameter: options A dictionary of presentation options. See PSPDFPresentationActions.h for possible values. - note: This will change style properties on this annotation state manager.

    Declaration

    Objective-C

    - (nullable PSPDFAnnotationStyleViewController *)
      toggleStylePicker:(nullable id)sender
    presentationOptions:(nullable NSDictionary<NSString *, id> *)options;

    Swift

    func toggleStylePicker(_ sender: Any?, presentationOptions options: [String : Any]? = nil) -> PSPDFAnnotationStyleViewController?

    Parameters

    sender

    A UIView or UIBarButtonItem used as the anchor view for the popover controller (iPad only).

    options

    A dictionary of presentation options. See PSPDFPresentationActions.h for possible values.

  • Displays a PSPDFSignatureViewController and toggles the state to PSPDFAnnotationStringSignature. - parameter: sender A UIView or UIBarButtonItem used as the anchor view for the popover controller (iPad only). - parameter: options A dictionary of presentation options. See PSPDFPresentationActions.h for possible values.

    Declaration

    Objective-C

    - (nullable UIViewController *)
    toggleSignatureController:(nullable id)sender
          presentationOptions:(nullable NSDictionary<NSString *, id> *)options;

    Swift

    func toggleSignatureController(_ sender: Any?, presentationOptions options: [String : Any]? = nil) -> Any!

    Parameters

    sender

    A UIView or UIBarButtonItem used as the anchor view for the popover controller (iPad only).

    options

    A dictionary of presentation options. See PSPDFPresentationActions.h for possible values.

  • Displays a PSPDFStampViewController and toggles the state to PSPDFAnnotationStringStamp. - parameter: sender A UIView or UIBarButtonItem used as the anchor view for the popover controller (iPad only). - parameter: includeSavedAnnotations Whether to include saved annotation using PSPDFSavedAnnotationsViewController or not. - parameter: options A dictionary of presentation options. See PSPDFPresentationActions.h for possible values.

    Declaration

    Objective-C

    - (nullable UIViewController *)
      toggleStampController:(nullable id)sender
    includeSavedAnnotations:(BOOL)includeSavedAnnotations
        presentationOptions:(nullable NSDictionary<NSString *, id> *)options;

    Swift

    func toggleStampController(_ sender: Any?, includeSavedAnnotations: Bool, presentationOptions options: [String : Any]? = nil) -> Any!

    Parameters

    sender

    A UIView or UIBarButtonItem used as the anchor view for the popover controller (iPad only).

    includeSavedAnnotations

    Whether to include saved annotation using PSPDFSavedAnnotationsViewController or not.

    options

    A dictionary of presentation options. See PSPDFPresentationActions.h for possible values.

  • Displays a PSPDFImagePickerController and toggles the state to PSPDFAnnotationStringImage. This will display an alert if the user selects UIImagePickerControllerSourceTypeCamera but does not grant permission. - parameter: sender A UIView or UIBarButtonItem used as the anchor view for the popover controller (iPad only). - parameter: options A dictionary of presentation options. See PSPDFPresentationActions.h for possible values.

    Declaration

    Objective-C

    - (nullable UIViewController *)
    toggleImagePickerController:(nullable id)sender
            presentationOptions:(nullable NSDictionary<NSString *, id> *)options;

    Swift

    func toggleImagePickerController(_ sender: Any?, presentationOptions options: [String : Any]? = nil) -> Any!

    Parameters

    sender

    A UIView or UIBarButtonItem used as the anchor view for the popover controller (iPad only).

    options

    A dictionary of presentation options. See PSPDFPresentationActions.h for possible values.