PSPDFDrawView
Objective-C
@interface PSPDFDrawView
: PSPDFContainerView <PSPDFAnnotationPresenting, PSPDFOverridable>
Swift
class DrawView : PDFContainerView, AnnotationPresenting, Overridable
PSPDFDrawView
allows drawing or erasing on top of a PDFPageView
and handles new annotation creation.
Unless otherwise noted, boxed points need to be of type PSPDFDrawingPoint
.
-
The
DrawView
delegate which is responsible for updating the Document with the changes made to the annotations.Declaration
Objective-C
@property (nonatomic, weak) id<PSPDFDrawViewDelegate> _Nullable delegate;
Swift
weak var delegate: DrawViewDelegate? { get set }
-
Current annotation type that is being created/edited.
Declaration
Objective-C
@property (nonatomic) PSPDFAnnotationType annotationType;
Swift
var annotationType: Annotation.Kind { get set }
-
The selected tool variant. Applied to new annotations.
Declaration
Objective-C
@property (nonatomic, nullable) PSPDFAnnotationVariantString annotationVariant;
Swift
var annotationVariant: Annotation.Variant? { get set }
-
Determines what effect touch events have. Defaults to
PSPDFDrawViewInputModeDraw
.PSPDFDrawViewInputModeErase
only affects Ink annotations.Declaration
Objective-C
@property (nonatomic) PSPDFDrawViewInputMode inputMode;
Swift
var inputMode: DrawView.InputMode { 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
allowedTouchTypes
s aredirect
,pencil
, andindirectPointer
.See
-[PSPDFAnnotationStateManager stylusMode]Declaration
Objective-C
@property (nonatomic, readonly) UIGestureRecognizer *_Nonnull drawGestureRecognizer;
Swift
var drawGestureRecognizer: UIGestureRecognizer { get }
-
Defines how ink annotations are created.
This determines whether a new annotation is created when a stroke ends.
See
PDFConfiguration
for details.Note
The default value for this setting is read from the current activePDFConfiguration
object.Declaration
Objective-C
@property (nonatomic) PSPDFDrawCreateMode drawCreateMode;
Swift
var drawCreateMode: DrawCreateMode { get set }
-
Enables natural drawing via tracking the pressure sensitivity of the points.
See
PDFConfiguration
for details.Note
The default value for this setting is read from the current activePDFConfiguration
object.Declaration
Objective-C
@property (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 (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’sscaleForPageView
. Defaults to 1.Declaration
Objective-C
@property (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’sscrollView.zoomScale
. Defaults to 1.Declaration
Objective-C
@property (nonatomic) CGFloat zoomScale;
Swift
var zoomScale: CGFloat { get set }
-
Current stroke color.
Declaration
Objective-C
@property (nonatomic, nullable) UIColor *strokeColor;
Swift
var strokeColor: UIColor? { get set }
-
Current fill color.
Declaration
Objective-C
@property (nonatomic, nullable) UIColor *fillColor;
Swift
var fillColor: UIColor? { get set }
-
Current line width.
Declaration
Objective-C
@property (nonatomic) CGFloat lineWidth;
Swift
var lineWidth: CGFloat { get set }
-
Starting line end type for lines and polylines.
Declaration
Objective-C
@property (nonatomic) PSPDFLineEndType lineEnd1;
Swift
var lineEnd1: AbstractLineAnnotation.EndType { get set }
-
Ending line end type for lines and polylines.
Declaration
Objective-C
@property (nonatomic) PSPDFLineEndType lineEnd2;
Swift
var lineEnd2: AbstractLineAnnotation.EndType { get set }
-
The stroke dash pattern. Draws a solid line when
nil
(default).Declaration
Objective-C
@property (nonatomic, copy, nullable) NSArray<NSNumber *> *dashArray;
Swift
var dashArray: [NSNumber]? { get set }
-
The border effect style.
Declaration
Objective-C
@property (nonatomic) PSPDFAnnotationBorderEffect borderEffect;
Swift
var borderEffect: Annotation.BorderEffect { 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 (nonatomic) CGFloat borderEffectIntensity;
Swift
var borderEffectIntensity: CGFloat { get set }
-
Defines a custom blend mode. Supported values include
kCGBlendModeNormal
tokCGBlendModeExclusion
.Declaration
Objective-C
@property (nonatomic) CGBlendMode blendMode;
Swift
var blendMode: CGBlendMode { get set }
-
Guide color. Defaults to
UIColor.pspdf_guideColor
.Declaration
Objective-C
@property (nonatomic, nullable) UIColor *guideBorderColor;
Swift
var guideBorderColor: UIColor? { get set }
-
All annotations currently managed by the draw view.
Declaration
Objective-C
@property (nonatomic, readonly) NSArray<PSPDFAnnotation *> *_Nonnull annotations;
Swift
var annotations: [Annotation] { 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, associated annotations and biometric data.
-
Point sequences that are in this draw view. An array of arrays holding
NSValue
s boxingPSPDFDrawingPoint
s.If this draw view is attached to a
PSPDFPageView
then the points are in the coordinate space of the PDF page that the page view is displaying, so the origin is in the bottom-left. UsePSPDFPageView.pdfCoordinateSpace
to convert these points to the coordinate space of the draw view. Alternatively, if this draw view is not attached to aPSPDFPageView
then the points are in the coordinate space of the draw view but scaled byscale
, so the origin is in the top-left.Point sequences is an empty array until
endDrawing
is invoked, unless the view was created using an existing annotation.Declaration
Objective-C
@property (nonatomic, readonly) NS_REFINED_FOR_SWIFT NSArray<NSArray<NSValue *> *> *pointSequences;
-
An array of boxed floating point values. Representing the intensity of each touch. Includes the same number of objects as
timePoints
andtouchRadii
.Note
Predictive touches are not tracked.Declaration
Objective-C
@property (nonatomic, readonly) NSArray<NSNumber *> *_Nonnull pressureList;
Swift
var pressureList: [NSNumber] { get }
-
An array of boxed
NSTimeInterval
s. Representing the timestamp of each touch. Includes the same number of objects aspressureList
andtouchRadii
.Note
Predictive touches are not tracked.Declaration
Objective-C
@property (nonatomic, readonly) NSArray<NSNumber *> *_Nonnull timePoints;
Swift
var timePoints: [NSNumber] { get }
-
An array of boxed floating point values. Representing the radius of each touch (or the altitude if an Apple Pencil was used). Includes the same number of objects as
pressureList
andtimePoints
.Note
Predictive touches are not tracked.Declaration
Objective-C
@property (nonatomic, readonly) NSArray<NSNumber *> *_Nonnull touchRadii;
Swift
var touchRadii: [NSNumber] { get }
-
The device that was used to create the signature.
When signing a document with the default UI, this is set to the last used input method of the created ink signature.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFDrawInputMethod inputMethod;
Swift
var inputMethod: DrawInputMethod { get }
-
Continues a drawing operation at with the given points and optional predicted points. The
inputMode
needs to bePSPDFDrawViewInputModeDraw
.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. -
Defines how aggressively shapes snap to square aspect ratio. Defaults to 20. Set to zero to disable guides.
Declaration
Objective-C
@property (nonatomic) CGFloat guideSnapAllowance;
Swift
var guideSnapAllowance: CGFloat { get set }
-
Point sequences that are in this draw view. An array of arrays holding
DrawingPoint
s.If this draw view is attached to a
PDFPageView
then the points are in the coordinate space of the PDF page that the page view is displaying, so the origin is in the bottom-left. UsePDFPageView.pdfCoordinateSpace
to convert these points to the coordinate space of the draw view. Alternatively, if this draw view is not attached to aPDFPageView
then the points are in the coordinate space of the draw view but scaled byscale
, so the origin is in the top-left.Point sequences is an empty array until
endDrawing
is invoked, unless the view was created using an existing annotation.Declaration
Swift
var pointSequences: [[DrawingPoint]] { get }
-
This publisher fires whenever the drawView’s
pointSequences
ordrawLayers
change.Declaration
Swift
var pointSequencesPublisher: AnyPublisher<[[DrawingPoint]], Never> { get }