How to format different characters in a UILabel string differently?

I have a UILabel with a dynamic string as the text property. If I always want the first word to be underlined, do I need to separate the labels, and then try to line them up correctly? Or could I subclass UILabel so that it does?

+4
source share
2 answers

Use a UIWebView and render the text as HTML.

+3
source

In the end, I used textRectForBounds:limitedToNumberOfLines: to find the dynamic start point of the word (minus some x coordinate pixels), and then removed the first letter uilabel with stringByReplacingCharactersInRange:withString: and then added another uilabel starting from the original label, only with in a different font.

0
source

Source: https://habr.com/ru/post/1340080/


All Articles