PSPDFResizableView
Objective-C
@interface PSPDFResizableView : UIView <PSPDFOverridable>
Swift
class ResizableView : UIView, Overridable
A view that shows borders around selected annotations, with handles the user can use to resize the annotation.
The handle and border color is determined by the tintColor
property inherited from UIView
.
-
Delegate called on frame change. Users can set this property to get callbacks.
Declaration
Objective-C
@property (nonatomic, weak) id<PSPDFResizableViewDelegate> _Nullable delegate;
Swift
@IBOutlet weak var delegate: ResizableViewDelegate? { get set }
-
The mode that the resizable view is currently in.
Declaration
Objective-C
@property (nonatomic) PSPDFResizableViewMode mode;
Swift
var mode: ResizableView.Mode { get set }
-
View that will be changed on selection change.
Declaration
Objective-C
@property (nonatomic, copy, nullable) NSSet<UIView *> *trackedViews;
Swift
var trackedViews: Set<UIView>? { get set }
-
The annotations corresponding to the
trackedViews
— cached.Declaration
Objective-C
@property (nonatomic, readonly) NSSet<PSPDFAnnotation *> *_Nonnull trackedAnnotations;
Swift
var trackedAnnotations: Set<PSPDFAnnotation> { get }
-
Set zoom scale to be able to draw the page knobs at the correct size.
Declaration
Objective-C
@property (nonatomic) CGFloat zoomScale;
Swift
var zoomScale: CGFloat { get set }
-
The insets of the selection border and resize knobs from the tracked annotation view. Since padding is usually desirable, the values of these insets should usually be negative. Defaults to -20.0 for top, bottom, right, and left.
These insets will be combined with
outerEdgeInsets
to map between the content size and center and the resizable view bounds and center.Note
updateAnnotationSelectionView
inPDFPageView
is used to set the inner edge insets of non-resizable annotations (e.g. note annotations) to -2 for top, bottom, right, and left (ignoring theinnerEdgeInsets
property). If you want to change this, you need to subclassPDFPageView
and overrideupdateAnnotationSelectionView
.Declaration
Objective-C
@property (nonatomic) UIEdgeInsets innerEdgeInsets;
Swift
var innerEdgeInsets: UIEdgeInsets { get set }
-
The insets of the resizable view bounds from the selection border and resize knobs. Subviews usually lie within the bounds of their superview, so the values of these insets should usually be negative. Defaults to -40.0 for top, bottom, right, and left.
These insets will be combined with
innerEdgeInsets
to map between the content size and center and the resizable view bounds and center.Declaration
Objective-C
@property (nonatomic) UIEdgeInsets outerEdgeInsets;
Swift
var outerEdgeInsets: UIEdgeInsets { get set }
-
If set to NO, won’t show selection knobs and dragging. Defaults to YES.
Declaration
Objective-C
@property (nonatomic) BOOL allowEditing;
Swift
var allowEditing: Bool { get set }
-
Allows view resizing, shows resize knobs. If set to NO, view can only be moved or adjusted, no resize knobs will be displayed. Depends on
allowEditing
. Defaults to YES.Declaration
Objective-C
@property (nonatomic) BOOL allowResizing;
Swift
var allowResizing: Bool { get set }
-
Allows view adjusting, shows knobs to move single points. If set to NO, view can only be moved or resized, no adjust knobs will be displayed. Depends on
allowEditing
. Defaults to YES.Declaration
Objective-C
@property (nonatomic) BOOL allowAdjusting;
Swift
var allowAdjusting: Bool { get set }
-
Whether to allow rotatable annotations to be rotated. Defaults to YES. Being able to rotate also depends on
allowEditing
.Declaration
Objective-C
@property (nonatomic) BOOL allowRotating;
Swift
var allowRotating: Bool { get set }
-
The rotation of the content in degrees, counterclockwise from horizontal.
Declaration
Objective-C
@property (nonatomic, readonly) NSUInteger contentRotation;
Swift
var contentRotation: UInt { get }
-
Enables resizing helper so that aspect ratio can be preserved easily. Defaults to YES.
Declaration
Objective-C
@property (nonatomic) BOOL enableResizingGuides;
Swift
var enableResizingGuides: Bool { get set }
-
Shows the bounding box. Defaults to YES.
Declaration
Objective-C
@property (nonatomic) BOOL showBoundingBox;
Swift
var showBoundingBox: Bool { get set }
-
Defines how aggressively the guide works. Defaults to 20.0. Set to
PSPDFGuideSnapAllowanceAlways
if you want to always snap to guides.Declaration
Objective-C
@property (nonatomic) CGFloat guideSnapAllowance;
Swift
var guideSnapAllowance: CGFloat { get set }
-
Override the minimum allowed width. This value is ignored if the view is smaller to begin with or the annotation specifies a bigger minimum width. Default is 0.0.
Declaration
Objective-C
@property (nonatomic) CGFloat minWidth;
Swift
var minWidth: CGFloat { get set }
-
Override the minimum allowed height. This value is ignored if the view is smaller to begin with or the annotation specifies a bigger minimum height. Default is 0.0.
Declaration
Objective-C
@property (nonatomic) CGFloat minHeight;
Swift
var minHeight: CGFloat { get set }
-
Border size. Defaults to 1.0.
Declaration
Objective-C
@property (nonatomic) CGFloat selectionBorderWidth;
Swift
var selectionBorderWidth: CGFloat { get set }
-
Guide color. Defaults to
UIColor.pspdf_guideColor
.Declaration
Objective-C
@property (nonatomic, nullable) UIColor *guideBorderColor;
Swift
var guideBorderColor: UIColor? { get set }
-
Corner radius size. Defaults to 0.
Declaration
Objective-C
@property (nonatomic) CGFloat cornerRadius;
Swift
var cornerRadius: CGFloat { get set }
-
Returns a specified knob view used to resize the annotation.
This will return nil if passed the type
.unknown
. If passed a valid knob type, the return value will not be nil.Knobs can be hidden individually by removing them from the superview like this:
outerKnob(ofType: .middleLeft)!.removeFromSuperview()
. Properties likeallowEditing
/allowResizing
will update theisHidden
property of the knob views, so just settingisHidden
to remove a knob will not be sufficient.There is typically no need to override this method.
Declaration
Objective-C
- (nullable UIView<PSPDFKnobView> *)outerKnobOfType: (PSPDFResizableViewOuterKnob)knobType;
-
The knob for rotating annotations that are rotatable. This will be hidden if the annotation does not support rotation or
allowRotating
is disabled.Declaration
Objective-C
@property (nonatomic, readonly) UIView<PSPDFKnobView> *_Nonnull rotationKnob;
Swift
var rotationKnob: UIView & KnobView { get }
-
Forward touches from a parent view’s gesture recognizer.
Declaration
Objective-C
- (void)forwardTouchesFromGestureRecognizer: (nonnull UIGestureRecognizer *)gestureRecognizer;
Swift
func forwardTouches(from gestureRecognizer: UIGestureRecognizer)
-
Returns the position for a resizing knob. May be overridden to customize the position.
Note
There is a known issue where altering this point may cause aspect ratio locked resizing to slightly change the aspect ratio. If you are experiencing this issue, please contact us at https://pspdfkit.com/support/request/
Declaration
Objective-C
- (CGPoint)centerPointForOuterKnob:(PSPDFResizableViewOuterKnob)knobType inFrame:(CGRect)frame;
Swift
func centerPoint(for knobType: ResizableView.OuterKnob, inFrame frame: CGRect) -> CGPoint
Parameters
knobType
The knob whose center position should be calculated.
frame
The frame in which the knob is positioned. Usually this is
self.bounds
, but during resizing, this might be different.Return Value
The center point of where the knob view should be placed.
-
Returns the point where the
rotationKnob
center should be placed. May be overridden to customize the position.Declaration
Objective-C
- (CGPoint)centerPointForRotationKnobInFrame:(CGRect)frame;
Swift
func centerPointForRotationKnob(inFrame frame: CGRect) -> CGPoint
Parameters
frame
The frame in which the knob is positioned. Usually this is
self.bounds
, but during resizing, this might be different.Return Value
The center point of where
rotationKnob
should be placed. -
Creates and configures a new knob view.
Override this to use custom views for the knobs.
This may be called before the resizable view has finished initializing so you must not refer to
self
in an override of this method. Doing so may result in a crash.Declaration
Objective-C
- (nonnull UIView<PSPDFKnobView> *)newKnobViewForType:(PSPDFKnobType)type;
-
Update the knobs.
Declaration
Objective-C
- (void)updateKnobsAnimated:(BOOL)animated;
Swift
func updateKnobs(animated: Bool)