MutableAttributedString连接

时间:2014-11-12 09:42:05

标签: nsstring ios8 nsmutableattributedstring

我试图连接到具有不同属性的属性字符串,但没有反映任何更改,在这里我的代码

//White color

NSMutableAttributedString *attributedString2 = [[NSMutableAttributedString alloc] initWithData:[[NSString stringWithFormat:@"%@",readingPartCntnt] dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
[attributedString2 addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0, attributedString2.length)];
[attributedString2 addAttribute:NSFontAttributeName value:font range:NSMakeRange(0, attributedString2.length)];

//Blue color

NSMutableAttributedString *attributedString3 = [[NSMutableAttributedString alloc] initWithData:[[NSString stringWithFormat:@"%@",readingFootCntnt] dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
[attributedString3 addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:(154.0/255.0) green:(224.0/255.0) blue:(250.0/255.0) alpha:1.0] range:NSMakeRange(0, attributedString3.length)];
[attributedString3 addAttribute:NSFontAttributeName value:font range:NSMakeRange(0, attributedString3.length)];
 //UITextview
 readingContent.attributedText = [NSMutableAttributedString attributedStringWithAttachment:attributedString2,attributedString3];

我想将 attributionString2 attributedString3 连接到readingContent。我的代码中需要进行哪些更改?请帮我解决

0 个答案:

没有答案