@Saurabh Shah" /> @Saurabh Shah" /> @Saurabh Shah"/>

UILabel detect userName from HTML text and change its font color?

48 Views Asked by At

I am getting following text from server.

"<span class='quill-mention' data-name='@Saurabh Shah
 (5327)' data-id='859155' user-id='859155'>@Saurabh Shah
 (5327)</span>  Test";

I want to make it like @Saurabh Shah Test

With @Saurabh Shah as Blue color font.

Currently I am using following code :

        NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithData:
                                            [self.message dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: [NSNumber numberWithInt:NSUTF8StringEncoding]} documentAttributes:nil error:nil];

That gives me string : @Saurabh Shah Test. But not blue color.

How can i do it?

1

There are 1 best solutions below

0
iMark On

Try to use this in your options:NSForegroundColorAttributeName