-1

I have a whole paragraph and I want to fit it in a label and be justified.Also, I want every line to have a specific range of words. I know that there is "Autoshrink" in Xcode, but it does not seem to work because I am trying it in a multiline text.

Here is an example of what I am trying to do https://i.stack.imgur.com/bNOKU.jpg. You can see how the text is fit into the label and is justified. However, not every line has the same number of characters. Is there a way to compress the text inside the label in swift?.

1 Answers1

0

Use a minimumFontSize for your label. It will allow you to fit all of your text in the label. Also, set your label's numberOfLines to 0 if you want label to automatically create multiple lines. Use this link for help.

Community
  • 1
  • 1
Pranav Wadhwa
  • 7,666
  • 6
  • 39
  • 61
  • Yes, that would work to fit all the test inside the label. However, thats not what I am stuck at. I am stuck at trying to stretch the text in each line to make the text in the label looks justified. – user2980554 Mar 09 '16 at 03:02
  • Ok. Sorry for the misunderstanding. Here is another [link](http://stackoverflow.com/questions/27060044/nstextalignment-justified-for-uilabel-does-not-work) to help you for justified labels. – Pranav Wadhwa Mar 09 '16 at 12:21
  • I took a look at what is in the link. It is viable for normal justification, but not the kind of justification I need. What I need is that I break the text lines in pieces, but then I need the label to stretch or compress the text to make it look justified. – user2980554 Mar 09 '16 at 19:00
  • Sorry I am not sure what you are asking. You should ask a different question and try to be more clear and precise about what you are looking for. – Pranav Wadhwa Mar 12 '16 at 20:20