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;
}
}];
コードは明らかに不完全であり、フォントに対してのみ実行しようとしているようです。NSMutableAttributedString
すべての属性をループして、新しい変数に追加したいと思います。NSMutableAttributedString
更新:私の質問は、すべての属性を別の属性に適用するにはどうすればよいNSMutableAttributedString
ですか? この方法を使用できますかsomehow:attribute:atIndex:effectiveRange