One search is the rtlabel of the entire article, nsattributestring rewriting draw method, etc. In fact, you just want a simple keyword to highlight the effect.
In fact, ios6 has provided a very simple solution (I don't know if I didn't discuss it with my colleagues)
As follows:
Nsstring * Title = titlestring;
Nsmutableattributedstring * titlestring = [[nsmutableattributedstring alloc] initwithstring: title];
If ([Title rangeofstring: keywords]. Length) {// highlighted keyword
[Titlestring addattriename: nsforegroundcolorattributename value: [uicolor] range: [Title rangeofstring: keywords];
}
_ Titlelabel. attributedtext = titlestring;
It's done.
In addition, we can mention
If some special characters such as () and numbers appear in rtlabel, do you have any questions about text display? I cannot solve this problem for the moment.
Uilabel keyword color