MutableAttributedString concatenation

138 views Asked by At

I have tried to concatenate to attributed string with different properties,But not reflecting any changes,Here my code

//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];

I want to concatenate both attributedString2 attributedString3 into readingContent.What change required in my code?Please help me to resolve

0

There are 0 answers