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)rangeParameters
- range
The affected string range
Declared In
NSMutableAttributedString+DTRichText.hcorrectParagraphSpacing
Method to correct paragraph styles on paragraphs belonging to list
- (void)correctParagraphSpacingDiscussion
Note: List support is not complete
Declared In
NSMutableAttributedString+DTRichText.hdeleteListPrefix
Deletes a list prefix from the receiver if there is one.
- (BOOL)deleteListPrefixReturn Value
YES if a list prefix field was deleted, NO if there was no prefix
Declared In
NSMutableAttributedString+DTRichText.henumerateAndUpdateFontInRange: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)blockParameters
- 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.henumerateAndUpdateParagraphStylesInRange: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)blockParameters
- 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.hmarkedRangeRemove:
Removing the marking from a marked range
- (NSRange)markedRangeRemove:(BOOL)removeParameters
- remove
YESif the marking should be cleared
Return Value
The range that is marked
Declared In
NSMutableAttributedString+DTRichText.hreplaceFont:inRange:
Replacing the UIFont for a range
- (void)replaceFont:(UIFont *)font inRange:(NSRange)rangeParameters
- font
The replacement front
- range
The range to repace the font in
Declared In
NSMutableAttributedString+DTRichText.hreplaceRange:withAttachment:inParagraph:
Convenience method to insert a DTTextAttachment.
- (NSUInteger)replaceRange:(NSRange)range withAttachment:(DTTextAttachment *)attachment inParagraph:(BOOL)inParagraphParameters
- range
The string range to insert the attachment at
- attachment
The text attachment to insert
- inParagraph
YESif the attachment should be placed in its own paragraph,NOto place it inline
Return Value
The length of the replacement string to allow for moving the cursor appropriately
Declared In
NSMutableAttributedString+DTRichText.hsetForegroundColor:inRange:
Sets the text foreground color.
- (void)setForegroundColor:(UIColor *)color inRange:(NSRange)rangeParameters
- color
The color to apply for the foreground color, or
nilto restore the default black color
- range
The affected string range
Declared In
NSMutableAttributedString+DTRichText.htoggleBoldInRange:
Toggles the given string range between bold and non-bold.
- (void)toggleBoldInRange:(NSRange)rangeParameters
- range
The affected string range
Declared In
NSMutableAttributedString+DTRichText.htoggleHighlightInRange:color:
Toggles the given string range between highlighted and non-highlighted.
- (void)toggleHighlightInRange:(NSRange)range color:(UIColor *)colorParameters
- 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.htoggleHyperlinkInRange:URL:
Toggles the given string range between having a hyperlink and not
- (void)toggleHyperlinkInRange:(NSRange)range URL:(NSURL *)URLParameters
- 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.htoggleItalicInRange:
Toggles the given string range between italic and non-italic.
- (void)toggleItalicInRange:(NSRange)rangeParameters
- range
The affected string range
Declared In
NSMutableAttributedString+DTRichText.htoggleParagraphSpacing:atIndex:spacing:
Sets or removes the space following the paragraph at the given index
- (void)toggleParagraphSpacing:(BOOL)spaceOn atIndex:(NSUInteger)index spacing:(CGFloat)spacingParameters
- 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.htoggleStrikethroughInRange:
Toggles the given string range between strikethrough and non-strikethrough.
- (void)toggleStrikethroughInRange:(NSRange)rangeParameters
- range
The affected string range
Declared In
NSMutableAttributedString+DTRichText.htoggleUnderlineInRange:
Toggles the given string range between underline and non-underline.
- (void)toggleUnderlineInRange:(NSRange)rangeParameters
- range
The affected string range
Declared In
NSMutableAttributedString+DTRichText.hupdateListStyle: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)removeNonPrefixedParameters
- listStyle
The list style to apply or
nilto 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