RendererView
open class RendererView : UIView
A scrollable, multiline text region capable of resizing itself based of the height of the content. Maximum height of RendererView
may be restricted using an absolute value or by using auto-layout constraints. Instantiation of RendererView is simple and straightforward
and can be used to host simple formatted text or complex layout containing multiple nested RendererView via use of Attachment.
-
An object interested in intercepting and responding to user interaction like tap and selecting changes in the
RendererView.Declaration
Swift
public weak var delegate: RendererViewDelegate? -
Undocumented
Declaration
Swift
public weak var listFormattingProvider: RendererListFormattingProvider? -
Context for the current renderer
Declaration
Swift
public let context: RendererViewContext -
Initializes the RendererView
Declaration
Swift
public init(frame: CGRect = .zero, context: RendererViewContext = .shared)Parameters
frameInitial frame to be used for
RendererViewcontextOptional context to be used.
RendererViewContextis link betweenRendererCommandExecutorand theRendererView.RendererCommandExecutorneeds to have same context as theRendererViewto execute a command on it. Unless you need to have restriction around some commands to be restricted in execution on certain specific renderers, the default value may be used. -
Default font to be used for the rendered content.
Note
This font is only applied in case where theattributedTextdoes not have font information in the content. If theattributedTextalready has an attribute applied for font, this font will be ignored.Declaration
Swift
public var font: UIFont { get set } -
Content rendered in the
RendererView.Declaration
Swift
public var attributedText: NSAttributedString { get set } -
Gets or sets the selected range.
Declaration
Swift
public var selectedRange: NSRange { get set } -
The types of data converted to tappable URLs in the renderer view.
Declaration
Swift
public var dataDetectorTypes: UIDataDetectorTypes { get set } -
The attributes to apply to links.
Declaration
Swift
public var linkTextAttributes: [NSAttributedString.Key : Any]! { get set } -
Selected text in the editor.
Declaration
Swift
public var selectedText: NSAttributedString { get } -
Returns the visible text range.
Note
The range may also contains lines that are partially visible owing to the current scroll position.Declaration
Swift
public var visibleRange: NSRange { get } -
Get all the content from
Renderer.See also
If you need to get content in a given range, please usecontents(in range:NSRange).Declaration
Swift
public var contents: [EditorContent] { get } -
Gets and sets the content offset.
Declaration
Swift
public var contentOffset: CGPoint { get set } -
Scrolls the given range to visible area of the
RendererView. The scroll only changes enough to make the range visible i.e. the it does not scroll far enough such that given range is centred in the visible area ofRenderer. No-op if the range is already visible.Declaration
Swift
public func scrollRangeToVisible(_ range: NSRange)Parameters
rangeRange to scroll to.
-
Scrolls the given rectangle to visible area of
RendererViewDeclaration
Swift
public func scrollRectToVisible(_ rect: CGRect, animated: Bool)Parameters
rectRectangle to scroll to.
animatedDetermines if the scroll action should animate
-
Gets the contents in the given range
Declaration
Swift
public func contents(in range: NSRange? = nil) -> [EditorContent]Parameters
rangeRange to get contents from.
-
Gets the bounding rectangles for the given range. If the range spans across multiple lines, in the
RendererView, a rectangle is returned for each of the line.Declaration
Swift
public func rects(for range: NSRange) -> [CGRect]Parameters
rangeRange to get bounding rectangles for.
-
Adds given attributes to the range provided. If the range already contains a value for an attribute being provided, existing value will be overwritten by the new value provided in the attributes.
Declaration
Swift
public func addAttributes(_ attributes: [NSAttributedString.Key : Any], at range: NSRange)Parameters
attributesAttributes to be added.
rangeRange on which attributes should be applied to.
-
Removes the given attributes from the range provided. If the attribute does not exist in the range, it will be a no-op.
Declaration
Swift
public func removeAttributes(_ attributes: [NSAttributedString.Key], at range: NSRange)Parameters
attributesAttributes to remove.
rangeRange to remove the attributes from.
-
Adds given attribute to the range provided. If the attribute already exists in the range, it will be overwritten with the new value provided here.
Declaration
Swift
public func addAttribute(_ name: NSAttributedString.Key, value: Any, at range: NSRange)Parameters
nameKey of the attribute to add.
valueValue of the attribute.
rangeRange to which attribute should be added.
-
Removes the attribute from given range. If the attribute does not exist in the range, it is a no-op.
Declaration
Swift
public func removeAttribute(_ name: NSAttributedString.Key, at range: NSRange)Parameters
nameKey of attribute to be removed.
rangeRange from which attribute should be removed.
View on GitHub
RendererView Class Reference