Hi I am trying to replace the attributedText of a UITextView subclass. I want to change the coloring of the text. to do so the following code is used:
AMR_ANSIEscapeHelper *ansiEscapeHelper = [[AMR_ANSIEscapeHelper alloc] init];
[ansiEscapeHelper setDefaultStringColor:[receiveView.highlightColor objectForKey:@"text"]];
NSMutableAttributedString *resultString = [receiveView.attributedText copy];
[receiveView setAttributedText:[ansiEscapeHelper attributedStringWithANSIEscapedString:[ansiEscapeHelper ansiEscapedStringWithAttributedString:resultString]]];
Problem is: The text does not get replaced; it just seem to add another layer of text, making the text color very strange. Do i need to assert some clearing before i set the Attributed Text the second time?
Here is how it looks: (The text should not be black, dark green and red)
)
子类RegexHighlightView包含另一种为文本着色的方法,因此字体会被涂上多种颜色!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.