UILabel and superscript

I have two lines:

  • variable length fragment
  • another line with the numbers that indicate the link

In my opinion, the first part of the text is displayed in UILabel, I adjust the size of the label to accommodate the size of the text. This means that I cannot just place another UILabel on the screen, at least without rearranging it ... somehow.

I need to be able to place the second piece of text so that it appears at the end of the sentence - and superscript

I really don't know how to achieve this!

+4
source share
2 answers

My pretty tricky solution was to enter Unicode characters for superscript numbers.

Not a great solution, but it worked.

+7
source

The easiest way is to use two different UILabels. A better solution would be to draw both lines using -drawInRect: withFont: in the custom view -drawRect: method.

+1
source

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


All Articles