4

I have two strings:

  • a variable length piece of text
  • another string with numbers that point to a reference

In my view, the first piece of text is displayed in a UILabel, I adjust the size of the label to accomodate the size of the text. This means I cannot just place another UILabel on the screen, at least not without repositioning it...somehow.

I need to be able to put the second piece of text so it appears to be at the end of the sentence - and superscripted

I really have no idea how to achieve this!

Chris James
  • 11,571
  • 11
  • 61
  • 89

2 Answers2

7

My rather dodgy solution was to enter unicode characters for the superscripted numbers.

Not a great solution but it worked.

Chris James
  • 11,571
  • 11
  • 61
  • 89
1

The simplest way would be to use two different UILabels. A better solution might be to draw both strings using -drawInRect:withFont: in a custom view's -drawRect: method.

Ben Gottlieb
  • 85,404
  • 22
  • 176
  • 172
  • How would I position them correctly though? The control in question can have varied length text so positioning the references at one point wont work – Chris James Feb 25 '10 at 14:18
  • Ah, if there's dynamic text, then you'll need to go the drawing route. – Ben Gottlieb Feb 25 '10 at 15:53
  • 2
    You could then use -sizeWithFont: to figure out how large your string will be when drawn, and place the second string in an appropriate location. – Brad Larson Feb 25 '10 at 18:30