ASTextNode Class Reference
Inherits from | ASControlNode : ASDisplayNode : ASDealloc2MainObject |
---|---|
Declared in | ASTextNode.h |
attributedText
The styled text displayed by the node.
@property (nullable, nonatomic, copy) NSAttributedString *attributedText
Discussion
Defaults to nil, no text is shown. For inline image attachments, add an attribute of key NSAttachmentAttributeName, with a value of an NSTextAttachment.
Declared In
ASTextNode.h
truncationAttributedText
The attributedText to use when the text must be truncated.
@property (nullable, nonatomic, copy) NSAttributedString *truncationAttributedText
Discussion
Defaults to a localized ellipsis character.
Declared In
ASTextNode.h
additionalTruncationMessage
@summary The second attributed string appended for truncation.
@property (nullable, nonatomic, copy) NSAttributedString *additionalTruncationMessage
Discussion
This string will be highlighted on touches. @default nil
Declared In
ASTextNode.h
truncationMode
Determines how the text is truncated to fit within the receiver’s maximum size.
@property (nonatomic, assign) NSLineBreakMode truncationMode
Discussion
Defaults to NSLineBreakByWordWrapping.
Note: Setting a truncationMode in attributedString will override the truncation mode set here.
Declared In
ASTextNode.h
truncated
If the text node is truncated. Text must have been sized first.
@property (nonatomic, readonly, assign, getter=isTruncated) BOOL truncated
Declared In
ASTextNode.h
maximumNumberOfLines
The maximum number of lines to render of the text before truncation. @default 0 (No limit)
@property (nonatomic, assign) NSUInteger maximumNumberOfLines
Declared In
ASTextNode.h
lineCount
The number of lines in the text. Text must have been sized first.
@property (nonatomic, readonly, assign) NSUInteger lineCount
Declared In
ASTextNode.h
exclusionPaths
An array of path objects representing the regions where text should not be displayed.
@property (nullable, nonatomic, strong) NSArray<UIBezierPath*> *exclusionPaths
Discussion
The default value of this property is an empty array. You can assign an array of UIBezierPath objects to exclude text from one or more regions in the text node’s bounds. You can use this property to have text wrap around images, shapes or other text like a fancy magazine.
Declared In
ASTextNode.h
placeholderEnabled
ASTextNode has a special placeholder behavior when placeholderEnabled is YES.
@property (nonatomic, assign) BOOL placeholderEnabled
Discussion
Defaults to NO. When YES, it draws rectangles for each line of text, following the true shape of the text’s wrapping. This visually mirrors the overall shape and weight of paragraphs, making the appearance of the finished text less jarring.
Declared In
ASTextNode.h
placeholderColor
The placeholder color.
@property (nullable, nonatomic, strong) UIColor *placeholderColor
Declared In
ASTextNode.h
placeholderInsets
Inset each line of the placeholder.
@property (nonatomic, assign) UIEdgeInsets placeholderInsets
Declared In
ASTextNode.h
shadowPadding
The number of pixels used for shadow padding on each side of the receiver.
@property (nonatomic, readonly, assign) UIEdgeInsets shadowPadding
Discussion
Each inset will be less than or equal to zero, so that applying UIEdgeInsetsRect(boundingRectForText, shadowPadding) will return a CGRect large enough to fit both the text and the appropriate shadow padding.
Declared In
ASTextNode.h
– rectsForTextRange:
Returns an array of rects bounding the characters in a given text range.
- (NSArray<NSValue*> *)rectsForTextRange:(NSRange)textRange
Parameters
textRange |
A range of text. Must be valid for the receiver’s string. |
---|
Discussion
Use this method to detect all the different rectangles a given range of text occupies. The rects returned are not guaranteed to be contiguous (for example, if the given text range spans a line break, the rects returned will be on opposite sides and different lines). The rects returned are in the coordinate system of the receiver.
Declared In
ASTextNode.h
– highlightRectsForTextRange:
Returns an array of rects used for highlighting the characters in a given text range.
- (NSArray<NSValue*> *)highlightRectsForTextRange:(NSRange)textRange
Parameters
textRange |
A range of text. Must be valid for the receiver’s string. |
---|
Discussion
Use this method to detect all the different rectangles the highlights of a given range of text occupies. The rects returned are not guaranteed to be contiguous (for example, if the given text range spans a line break, the rects returned will be on opposite sides and different lines). The rects returned are in the coordinate system of the receiver. This method is useful for visual coordination with a highlighted range of text.
Declared In
ASTextNode.h
– frameForTextRange:
Returns a bounding rect for the given text range.
- (CGRect)frameForTextRange:(NSRange)textRange
Parameters
textRange |
A range of text. Must be valid for the receiver’s string. |
---|
Discussion
The height of the frame returned is that of the receiver’s line-height; adjustment for cap-height and descenders is not performed. This method raises an exception if textRange is not a valid substring range of the receiver’s string.
Declared In
ASTextNode.h
– trailingRect
Returns the trailing rectangle of space in the receiver, after the final character.
- (CGRect)trailingRect
Discussion
Use this method to detect which portion of the receiver is not occupied by characters. The rect returned is in the coordinate system of the receiver.
Declared In
ASTextNode.h
linkAttributeNames
The set of attribute names to consider links. Defaults to NSLinkAttributeName.
@property (nonatomic, copy) NSArray<NSString*> *linkAttributeNames
Declared In
ASTextNode.h
– linkAttributeValueAtPoint:attributeName:range:
Indicates whether the receiver has an entity at a given point.
- (nullable id)linkAttributeValueAtPoint:(CGPoint)point attributeName:(out NSString *_Nullable *_Nullable)attributeNameOut range:(out NSRange *_Nullable)rangeOut
Parameters
point |
The point, in the receiver’s coordinate system. |
---|---|
attributeNameOut |
The name of the attribute at the point. Can be NULL. |
rangeOut |
The ultimate range of the found text. Can be NULL. |
Return Value
YES if an entity exists at point
; NO otherwise.
Declared In
ASTextNode.h
highlightStyle
The style to use when highlighting text.
@property (nonatomic, assign) ASTextNodeHighlightStyle highlightStyle
Declared In
ASTextNode.h
highlightRange
The range of text highlighted by the receiver. Changes to this property are not animated by default.
@property (nonatomic, assign) NSRange highlightRange
Declared In
ASTextNode.h
– setHighlightRange:animated:
Set the range of text to highlight, with optional animation.
- (void)setHighlightRange:(NSRange)highlightRange animated:(BOOL)animated
Parameters
highlightRange |
The range of text to highlight. |
---|---|
animated |
Whether the text should be highlighted with an animation. |
Declared In
ASTextNode.h
delegate
Responds to actions from links in the text node.
@property (nonatomic, weak) id<ASTextNodeDelegate> delegate
Discussion
The delegate must be set before the node is loaded, and implement textNode:longPressedLinkAttribute:value:atPoint:textRange: in order for the long press gesture recognizer to be installed.
Declared In
ASTextNode.h
longPressCancelsTouches
If YES and a long press is recognized, touches are cancelled. Default is NO
@property (nonatomic, assign) BOOL longPressCancelsTouches
Declared In
ASTextNode.h
passthroughNonlinkTouches
if YES will not intercept touches for non-link areas of the text. Default is NO.
@property (nonatomic, assign) BOOL passthroughNonlinkTouches
Declared In
ASTextNode.h