PSPDFTextSelectionView


@interface PSPDFTextSelectionView : UIView <AVSpeechSynthesizerDelegate>

Handles text and image selection. - note: Requires the PSPDFFeatureMaskTextSelection feature flag. Don’t manually create this class. The initializer here is not exposed. The selection color is determined by the tintColor property inherited from UIView.

  • The text selection delegate.

    Declaration

    Objective-C

    @property (readwrite, nonatomic)
        id<PSPDFTextSelectionViewDelegate> _Nullable delegate;

    Swift

    weak var delegate: PSPDFTextSelectionViewDelegate? { get set }
  • Currently selected glyphs. - note: Use sortedGlyphs: to pre-sort your glyphs if you manually set this. - warning: This method expects glyphs to be sorted from top->bottom and left->right for performance reasons.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, null_resettable)
        NSArray<PSPDFGlyph *> *selectedGlyphs;

    Swift

    var selectedGlyphs: [PSPDFGlyph]! { get set }
  • Currently selected text. Set via setting selectedGlyphs. Use discardSelection to clear.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSString *selectedText;

    Swift

    var selectedText: String? { get }
  • Currently selected image.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, nullable) PSPDFImageInfo *selectedImage;

    Swift

    var selectedImage: PSPDFImageInfo? { get set }
  • The selection alpha value. Defaults to UIColor.pspdf_selectionAlpha.

    Declaration

    Objective-C

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

    Swift

    var selectionAlpha: CGFloat { get set }
  • Currently selected text, optimized for searching

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSString *trimmedSelectedText;

    Swift

    var trimmedSelectedText: String? { get }
  • To make it easier to select text, we slightly increase the frame margins. Defaults to 4 pixels.

    Declaration

    Objective-C

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

    Swift

    var selectionHitTestExtension: CGFloat { get set }
  • Rectange of the first line of the current selection, in view coordinate space.

    Declaration

    Objective-C

    @property (readonly, nonatomic) CGRect firstLineRect;

    Swift

    var firstLineRect: CGRect { get }
  • Rectangle between the first and last lines of the current selection, in view coordinate space.

    Declaration

    Objective-C

    @property (readonly, nonatomic) CGRect innerRect;

    Swift

    var innerRect: CGRect { get }
  • Rectangle of the last line of the current selection, in view coordinate space.

    Declaration

    Objective-C

    @property (readonly, nonatomic) CGRect lastLineRect;

    Swift

    var lastLineRect: CGRect { get }
  • Updates the UIMenuController if there is a selection. Returns YES if a menu is displayed.

    Declaration

    Objective-C

    - (BOOL)updateMenuAnimated:(BOOL)animated;

    Swift

    func updateMenu(animated: Bool) -> Bool
  • Update the selection (text menu). - note: animated is currently ignored.

    Declaration

    Objective-C

    - (void)updateSelectionAnimated:(BOOL)animated;

    Swift

    func updateSelection(animated: Bool)
  • Clears the current selection.

    Declaration

    Objective-C

    - (void)discardSelectionAnimated:(BOOL)animated;

    Swift

    func discardSelection(animated: Bool)
  • Required if glyph frames change.

    Declaration

    Objective-C

    - (void)clearCache;

    Swift

    func clearCache()
  • Currently has a text/image selection?

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL hasSelection;

    Swift

    var hasSelection: Bool { get }
  • Debugging feature, visualizes the text blocks.

    Declaration

    Objective-C

    - (void)showTextFlowData:(BOOL)show animated:(BOOL)animated;

    Swift

    func showTextFlowData(_ show: Bool, animated: Bool)