Desidero copiare tutti gli attributi da uno NSMutableAttributedString
in uno nuovo. Il codice che ho provato è questo:iOS - copia tutti gli attributi NSMutableAttributedString su un'altra NSMutableAttributedString
[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;
}
}];
il codice è chiaramente incompleta e sembra che il suo tentativo di farlo per solo font. Vorrei scorrere ogni attributo e aggiungerlo a una nuova variabile NSMutableAttributedString
. Aggiornamento: la mia domanda è: come posso applicare tutti gli attributi di uno NSMutableAttributedString
a un altro NSMutableAttributedString
? Possiamo utilizzare questo metodo somehow:attribute:atIndex:effectiveRange
Qual è la tua domanda? – Dima
la mia domanda è: come posso applicare tutti gli attributi di una NSMutableAttributedString a un'altra NSMutableAttributedString? – j2emanue
Vedere la mia risposta per il modo corretto di farlo. – Dima