UILabel and superscript

泄露秘密 提交于 2020-01-02 06:19:24

问题


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!


回答1:


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

Not a great solution but it worked.




回答2:


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.



来源:https://stackoverflow.com/questions/2334501/uilabel-and-superscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!