[attributedString enumerateAttributesInRange:range options:NSAttributedStringEnumerationReverse usingBlock:
^(NSDictionary *attributes, NSRange range, BOOL *stop) {
NSMutableDictionary *mutableAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes];
[mutableAttributes setObject:[NSNumber numberWithInt:1] forKey:@"NSUnderline"];
attributes = mutableAttributes;
}];
私はすべての属性をループし、それらにNSUnderlineを追加しようとしています。 NSUnderlineがディクショナリに追加されたようにデバッグすると思われますが、2回目にループすると削除されます。 NSDictionariesの更新中に何か間違っていますか?目的C - NSAttributedStringのすべての属性を変更しますか?
あなたはattributedStringに関する私の他の質問を見ることができますか?ありがとうございます:http://stackoverflow.com/questions/6783754/objective-c-nsattributedstring-extend-attributes – aryaxt
'addAttribute:value:range:'同じ値を持つ既存の値を同じ範囲で上書きしますか?それとも、属性を追加しないだけですか? – chown
@chownドキュメンテーションは言いませんので、私はそれをテストし、既存の値を上書きすることを確認します。 – ughoavgfhw