Remove all of the attributes using setAttributes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSMutableAttributedString *originalMutableAttributedString = //your string… | |
NSRange originalRange = NSMakeRange(0, originalMutableAttributedString.length); | |
[originalMutableAttributedString setAttributes:@{} range:originalRange]; |
Or try doing this conditionally and enumerating the attributes to remove them one-by-one:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[originalMutableAttributedString enumerateAttributesInRange:originalRange | |
options:kNilOptions | |
usingBlock:^(NSDictionary *attrs, NSRange range, BOOL *stop) { | |
[attrs enumerateKeysAndObjectsUsingBlock:^(NSString *attribute, id obj, BOOL *stop) { | |
[originalMutableAttributedString removeAttribute:attribute range:range]; | |
}]; | |
}]; |