mattt/TTTAttributedLabel — Issue #34: Request a new method to combine inherited attributes with new AttrString
Author: AndrewSmall
Created: 2011-12-09 22:27:39+00:00
State: open

I am using the following method in a class extension that you may find useful to incorporate into the code.
I combines any attributes on the given NSAttributedString with the attributes that it inherits from the label.

- (void)inheritAttributesAndSetText:(NSAttributedString *)text {
[self setText:text afterInheritingLabelAttributesAndConfiguringWithBlock:^(NSMutableAttributedString *labelString){
[text enumerateAttributesInRange:NSMakeRange(0, text.string.length)
options:0
usingBlock:^(NSDictionary *attrs, NSRange range, BOOL *stop){
[labelString addAttributes:attrs range:range];
}];
return labelString;
}];
}