CKTextKitRenderer(Positioning) Category Reference
Declared in | CKTextKitRenderer+Positioning.h |
---|
– frameForTextRange:
Returns the bounding rect for the given character range.
- (CGRect)frameForTextRange:(NSRange)textRange
Parameters
textRange |
The character range for which the bounding rect will be computed. Should be within the range of the attributedString of this renderer. |
---|
Discussion
In the external, shadowed coordinate space.
Declared In
CKTextKitRenderer+Positioning.h
– rectsForTextRange:measureOption:
Returns an array of rects representing the lines in the given character range
- (NSArray *)rectsForTextRange:(NSRange)textRange measureOption:(CKTextKitRendererMeasureOption)measureOption
Parameters
textRange |
The character range for which the rects will be computed. Should be within the range of the attributedString of this renderer. |
---|---|
measureOption |
The measure option to use for construction of the rects. See CKTextKitRendererMeasureOption docs for usage. |
Discussion
This method is useful for providing highlighting text. Returned rects are in the coordinate space of the renderer.
Triggers initialization of textkit components, truncation, and sizing.
Declared In
CKTextKitRenderer+Positioning.h
– enumerateTextIndexesAtPosition:usingBlock:
Enumerate the text character indexes at a position within the coordinate space of the renderer.
- (void)enumerateTextIndexesAtPosition:(CGPoint)position usingBlock:(ck_text_component_index_block_t)block
Parameters
position |
The point in the shadowed coordinate space at which text indexes will be enumerated. |
---|---|
block |
The block that will be executed for each index identified that may correspond to the given position. The block is given the character index that corresponds to the glyph at each index in question, as well as the bounding rect for that glyph. |
Discussion
Glyph location based on a touch point is not an exact science because user touches are not well-represented by a simple point, especially in the context of link-heavy text. So we have this method to make it a bit easier. This method checks a grid of candidate positions around the touch point you give it, and computes the bounding rect of the glyph corresponding to the character index given.
The bounding rect of the glyph can be used to identify the best glyph index that corresponds to your touch. For instance, comparing centroidal distance from the glyph bounding rect to the touch center is useful for identifying which link a user actually intended to select.
Triggers initialization of textkit components, truncation, and sizing.
Declared In
CKTextKitRenderer+Positioning.h
– nearestTextIndexAtPosition:
Returns the single text index whose glyph’s centroid is closest to the given position.
- (NSUInteger)nearestTextIndexAtPosition:(CGPoint)position
Parameters
position |
The point in the shadowed coordinate space that should be checked. |
---|
Discussion
This will use the grid enumeration function above, enumerateTextIndexesAtPosition...
, in order to find
the closest glyph, so it is possible that a glyph could be missed, but ultimately unlikely.
Declared In
CKTextKitRenderer+Positioning.h
– trailingRect
Returns the trailing rect unused by the renderer in the last rendered line.
- (CGRect)trailingRect
Discussion
In the external shadowed coordinate space.
Triggers initialization of textkit components, truncation, and sizing.
Declared In
CKTextKitRenderer+Positioning.h