PSPDFDrawView

PSPDFDrawView allows drawing or erasing on top of a PSPDFPageView and handles new annotation creation.

Unless otherwise noted, boxed points need to be of type PSPDFDrawingPoint.

  • Current annotation type that is being created/edited.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) PSPDFAnnotationType annotationType;

    Swift

    var annotationType: AnnotationType { get set }
  • The selected tool variant. Applied to new annotations.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, nullable) NSString *annotationVariant;

    Swift

    var annotationVariant: String? { get set }
  • Determines what effect touch events have. Defaults to PSPDFDrawViewInputModeDraw. PSPDFDrawViewInputModeErase only affects Ink annotations.

    Declaration

    Objective-C

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

    Swift

    var inputMode: PSPDFDrawViewInputMode { get set }
  • The gesture recognizer used to detect drawings.

    Setting its allowedTouchTypes property can be used to limit the allowed types however the draw view may still ignore touches even if they are in the list of allowed types. This is used for Apple Pencil support.

    The default allowedTouchTypess are UITouchTypeDirect and UITouchTypeStylus.

    See

    -[PSPDFAnnotationStateManager stylusMode]

    Declaration

    Objective-C

    @property (readonly, nonatomic)
        UIGestureRecognizer *_Nonnull drawGestureRecognizer;

    Swift

    var drawGestureRecognizer: UnsafeMutablePointer<Int32> { get }
  • Defines how ink annotations are created.

    See

    PSPDFConfiguration for details.

    Note

    The default value for this setting is read from the current active PSPDFConfiguration object.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) PSPDFDrawCreateMode drawCreateMode;

    Swift

    var drawCreateMode: PSPDFDrawCreateMode { get set }
  • Enables natural drawing via tracking the pressure sensitivity of the points.

    See

    PSPDFConfiguration for details.

    Note

    The default value for this setting is read from the current active PSPDFConfiguration object.

    Declaration

    Objective-C

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

    Swift

    var naturalDrawingEnabled: Bool { get set }
  • Enables the use of predictive touches. Defaults to NO. Enabling this for ink annotation improves the drawing experience.

    Declaration

    Objective-C

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

    Swift

    var predictiveTouchesEnabled: Bool { get set }
  • Used to compute approximate line widths during drawing. When a pageView is associated this will automatically be set to it’s scaleForPageView. Defaults to 1.f.

    Declaration

    Objective-C

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

    Swift

    var scale: CGFloat { get set }
  • Draw view zoom scale, used for zoom dependent eraser sizing. When a pageView is associated this will automatically be set to it’s scrollView.zoomScale. Defaults to 1.f.

    Declaration

    Objective-C

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

    Swift

    var zoomScale: CGFloat { get set }
  • Current stroke color.

    Declaration

    Objective-C

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

    Swift

    var strokeColor: NSColor? { get set }
  • Current fill color.

    Declaration

    Objective-C

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

    Swift

    var fillColor: NSColor? { get set }
  • Current line width.

    Declaration

    Objective-C

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

    Swift

    var lineWidth: CGFloat { get set }
  • Starting line end type for lines and polylines.

    Declaration

    Objective-C

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

    Swift

    var lineEnd1: PSPDFLineEndType { get set }
  • Ending line end type for lines and polylines.

    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). A number describing the intensity of the effect, in the range 0 to 2. Default value: 0.

    Declaration

    Objective-C

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

    Swift

    var borderEffectIntensity: CGFloat { get set }
  • Defines a custom blend mode. Supported values include kCGBlendModeNormal to kCGBlendModeExclusion.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGBlendMode blendMode;

    Swift

    var blendMode: CGBlendMode { get set }
  • Guide color. Defaults to UIColor.pspdf_guideColor.

    Declaration

    Objective-C

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

    Swift

    var guideBorderColor: NSColor? { get set }
  • All annotations currently managed by the draw view.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSArray<PSPDFAnnotation *> *_Nonnull annotations;

    Swift

    var annotations: [PSPDFAnnotation] { get }
  • Adds the provided annotations to the draw view, making them available for editing.

    Note

    Currently only supports Ink annotations (to facilitate ink erasing).

    Declaration

    Objective-C

    - (void)updateForAnnotations:
        (nonnull NSArray<PSPDFInkAnnotation *> *)annotations;

    Swift

    func update(for annotations: [PSPDFInkAnnotation])
  • Clears all drawings and associated annotations. Registers as a single undo action, if undo is supported.

    Declaration

    Objective-C

    - (void)clear;

    Swift

    func clear()
  • Starts a drawing operation at the given point. The inputMode needs to be set to PSPDFDrawViewInputModeDraw.

    Declaration

    Objective-C

    - (void)startDrawingAtPoint:(PSPDFDrawingPoint)location;

    Swift

    func startDrawing(at location: PSPDFDrawingPoint)
  • Continues a drawing operation at with the given points and optional predicted points. The inputMode needs to be PSPDFDrawViewInputModeDraw.

    Declaration

    Objective-C

    - (void)continueDrawingAtPoints:(nonnull NSArray<NSValue *> *)locations
                    predictedPoints:
                        (nonnull NSArray<NSValue *> *)predictedLocations;

    Swift

    func continueDrawing(atPoints locations: [NSValue], predictedPoints predictedLocations: [NSValue])

    Parameters

    locations

    Boxed PSPDFDrawingPoint objects.

    predictedLocations

    Boxed PSPDFDrawingPoint objects.

  • Commits the drawing. The inputMode needs to be set to PSPDFDrawViewInputModeDraw.

    Declaration

    Objective-C

    - (void)endDrawing;

    Swift

    func endDrawing()
  • Cancels the drawing. The inputMode needs to be set to PSPDFDrawViewInputModeDraw.

    Declaration

    Objective-C

    - (void)cancelDrawing;

    Swift

    func cancelDrawing()
  • Defines how aggressively shapes snap to square aspect ratio. Defaults to 20. Set to zero to disable guides.

    Declaration

    Objective-C

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

    Swift

    var guideSnapAllowance: CGFloat { get set }
  • Performs an erase at the given locations. Boxed PSDFDrawingPoint objects. The inputMode needs to be set to PSPDFDrawViewInputModeErase.

    Declaration

    Objective-C

    - (void)eraseAt:(nonnull NSArray<NSValue *> *)locations;

    Swift

    func erase(at locations: [NSValue])
  • Commits the erase operation (registers the undo action, etc.). The inputMode needs to be set to PSPDFDrawViewInputModeErase.

    Declaration

    Objective-C

    - (void)endErase;

    Swift

    func endErase()