Ich mag würde alle Attribute von einem NSMutableAttributedString
in eine neue kopieren. Der Code, den ich versucht habe, ist dies:iOS - kopieren Sie alle NSMutableAttributedString auf einen anderen NSMutableAttributedString Attribute
[attrStr enumerateAttribute:NSFontAttributeName inRange:NSMakeRange(0, attrStr.length) options:0 usingBlock:^(id value, NSRange range, BOOL *stop) {
if (value) {
// UIFont *oldFont = (UIFont *)value;
UIFont *newFont = [_label.attributedText
[attrStr removeAttribute:NSFontAttributeName range:range];
[attrStr addAttribute:NSFontAttributeName value:newFont range:range];
//found = YES;
}
}];
der Code eindeutig unvollständig ist und es sieht aus wie seine versucht, es nur für Schriften zu tun. Ich möchte jedes Attribut durchlaufen und es in eine neue NSMutableAttributedString
Variable hinzufügen. Aktualisieren: meine Frage ist, wie bewerbe ich alle Attribute einer NSMutableAttributedString
zu einem anderen NSMutableAttributedString
? Können wir diese Methode somehow:attribute:atIndex:effectiveRange
Was ist Ihre Frage? – Dima
meine Frage ist, wie bewerbe ich alle Attribute einer NSMutableAttributedString zu einem anderen NSMutableAttributedString? – j2emanue
Siehe meine Antwort für den richtigen Weg, dies zu tun. – Dima