我有一段我正在使用 NSMutableParagraphStyle 来管理行高。另外,我想更改段落中一个单词的颜色,这是我正在使用的代码,但它只是更改了一个单词的颜色(attributedText 被覆盖)我该如何解决?有什么帮助吗??
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineHeightMultiple = 1.45f;
paragraphStyle.alignment = UITextAlignmentRight;
NSDictionary *ats = @{
NSFontAttributeName : [UIFont fontWithName:@"Helvetica"
size:currentSize],
NSParagraphStyleAttributeName : paragraphStyle,
};
ayaTxt.attributedText = [[NSAttributedString alloc] initWithString:ayaTxt.text
attributes:ats];
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc]
initWithString:ayaTxt.text];
NSRange range = [[AyatWords objectAtIndex:aya] rangeOfString:@":"];
[attrString addAttribute:NSForegroundColorAttributeName
value:[UIColor colorWithRed:(25.0/255.0)
green:(168.0/255.0)
blue:(167.0/255.0)
alpha:1.0]
range:NSMakeRange(0, range.location + 1)];
ayaTxt.attributedText = attrString;
谢谢 ..