NSMutableAttributedString(DTRichText) Category Reference
Declared in | NSMutableAttributedString+DTRichText.h |
Tasks
Modifying Text
Toggling Styles
-
– toggleBoldInRange:
-
– toggleItalicInRange:
-
– toggleUnderlineInRange:
-
– toggleStrikethroughInRange:
-
– toggleHighlightInRange:color:
-
– setForegroundColor:inRange:
-
– toggleHyperlinkInRange:URL:
Working with Fonts
Working with Paragraph Styles
-
– enumerateAndUpdateParagraphStylesInRange:block:
-
– toggleParagraphSpacing:atIndex:spacing:
-
– correctParagraphSpacing
Working with Lists
-
– updateListStyle:inRange:numberFrom:listIndent:spacingAfterList:removeNonPrefixedParagraphsFromList:
-
– deleteListPrefix
Marking Ranges
Instance Methods
addMarkersForSelectionRange:
Adding a marked range
- (void)addMarkersForSelectionRange:(NSRange)range
Parameters
- range
The affected string range
Declared In
NSMutableAttributedString+DTRichText.h
correctParagraphSpacing
Method to correct paragraph styles on paragraphs belonging to list
- (void)correctParagraphSpacing
Discussion
Note: List support is not complete
Declared In
NSMutableAttributedString+DTRichText.h
deleteListPrefix
Deletes a list prefix from the receiver if there is one.
- (BOOL)deleteListPrefix
Return Value
YES
if a list prefix field was deleted, NO
if there was no prefix
Declared In
NSMutableAttributedString+DTRichText.h
enumerateAndUpdateFontInRange:block:
Enumerates the font styles for a given range. If the block returns YES
then the font will be updated with changes made to the fontDescriptor parameter.
Note: This does not extend the range to include full paragraphs as enumerateAndUpdateParagraphStylesInRange:block: does.
- (BOOL)enumerateAndUpdateFontInRange:(NSRange)range block:(NSMutableAttributedStringFontStyleEnumerationBlock)block
Parameters
- range
The range to update
- block
The block to execute for each font range
Return Value
YES
if at least one font has been updated
Declared In
NSMutableAttributedString+DTRichText.h
enumerateAndUpdateParagraphStylesInRange:block:
Enumerates the paragraph styles for a given range extended to contain full paragraphs. If the block returns YES
then the paragraph style for the paragraph is updated with changes made to the paragraphStyle parameter.
- (BOOL)enumerateAndUpdateParagraphStylesInRange:(NSRange)range block:(NSMutableAttributedStringParagraphStyleEnumerationBlock)block
Parameters
- range
The range to update
- block
The block to execute for each paragraph
Return Value
YES
if at least one paragraph has been updated
Declared In
NSMutableAttributedString+DTRichText.h
markedRangeRemove:
Removing the marking from a marked range
- (NSRange)markedRangeRemove:(BOOL)remove
Parameters
- remove
YES
if the marking should be cleared
Return Value
The range that is marked
Declared In
NSMutableAttributedString+DTRichText.h
replaceFont:inRange:
Replacing the UIFont
for a range
- (void)replaceFont:(UIFont *)font inRange:(NSRange)range
Parameters
- font
The replacement front
- range
The range to repace the font in
Declared In
NSMutableAttributedString+DTRichText.h
replaceRange:withAttachment:inParagraph:
Convenience method to insert a DTTextAttachment.
- (NSUInteger)replaceRange:(NSRange)range withAttachment:(DTTextAttachment *)attachment inParagraph:(BOOL)inParagraph
Parameters
- range
The string range to insert the attachment at
- attachment
The text attachment to insert
- inParagraph
YES
if the attachment should be placed in its own paragraph,NO
to place it inline
Return Value
The length of the replacement string to allow for moving the cursor appropriately
Declared In
NSMutableAttributedString+DTRichText.h
setForegroundColor:inRange:
Sets the text foreground color.
- (void)setForegroundColor:(UIColor *)color inRange:(NSRange)range
Parameters
- color
The color to apply for the foreground color, or
nil
to restore the default black color
- range
The affected string range
Declared In
NSMutableAttributedString+DTRichText.h
toggleBoldInRange:
Toggles the given string range between bold and non-bold.
- (void)toggleBoldInRange:(NSRange)range
Parameters
- range
The affected string range
Declared In
NSMutableAttributedString+DTRichText.h
toggleHighlightInRange:color:
Toggles the given string range between highlighted and non-highlighted.
- (void)toggleHighlightInRange:(NSRange)range color:(UIColor *)color
Parameters
- range
The affected string range
- color
The color to apply for the highlight
Discussion
The color parameter is ignored if the method call toggles a previous URL off.
Declared In
NSMutableAttributedString+DTRichText.h
toggleHyperlinkInRange:URL:
Toggles the given string range between having a hyperlink and not
- (void)toggleHyperlinkInRange:(NSRange)range URL:(NSURL *)URL
Parameters
- range
The affected string range
- URL
The hyperlink URL to apply for the string
Discussion
The URL parameter is ignored if the method call toggles a previous URL off.
Declared In
NSMutableAttributedString+DTRichText.h
toggleItalicInRange:
Toggles the given string range between italic and non-italic.
- (void)toggleItalicInRange:(NSRange)range
Parameters
- range
The affected string range
Declared In
NSMutableAttributedString+DTRichText.h
toggleParagraphSpacing:atIndex:spacing:
Sets or removes the space following the paragraph at the given index
- (void)toggleParagraphSpacing:(BOOL)spaceOn atIndex:(NSUInteger)index spacing:(CGFloat)spacing
Parameters
- spaceOn
If yes then the default paragraph space is added
- index
The string index in the affected paragraph
- spacing
When toggling spacing on this is the spacing to apply
Declared In
NSMutableAttributedString+DTRichText.h
toggleStrikethroughInRange:
Toggles the given string range between strikethrough and non-strikethrough.
- (void)toggleStrikethroughInRange:(NSRange)range
Parameters
- range
The affected string range
Declared In
NSMutableAttributedString+DTRichText.h
toggleUnderlineInRange:
Toggles the given string range between underline and non-underline.
- (void)toggleUnderlineInRange:(NSRange)range
Parameters
- range
The affected string range
Declared In
NSMutableAttributedString+DTRichText.h
updateListStyle:inRange:numberFrom:listIndent:spacingAfterList:removeNonPrefixedParagraphsFromList:
Convenience method to update list styling on entire paragraphs
- (void)updateListStyle:(DTCSSListStyle *)listStyle inRange:(NSRange)range numberFrom:(NSInteger)nextItemNumber listIndent:(CGFloat)listIndent spacingAfterList:(CGFloat)spacingAfterList removeNonPrefixedParagraphsFromList:(BOOL)removeNonPrefixed
Parameters
- listStyle
The list style to apply or
nil
to remove list styling
- range
The range to update
- nextItemNumber
For numbered lists this is the next number to use
- listIndent
The indent from leading margin to indent list paragraphs at
- spacingAfterList
The spacing to apply on the last paragraph of the list
- removeNonPrefixed
Whether paragraphs that have no list prefix should be removed from lists
Declared In
NSMutableAttributedString+DTRichText.h