Author Topic: UILabel line break/formatting  (Read 1914 times)

MoProductions

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 45
    • View Profile
UILabel line break/formatting
« on: October 02, 2017, 10:53:44 AM »
We're using a UILabel to display some text info about our game.  We've got it anchored so it forces the Overflow to Shrink Content, which works fine most of the time but we're not happy with the way the line breaks sometimes.  For example, this is one of those cases:



What we want to be able to do is avoid the situation where the 2nd line is very short compared to the top line, so it looks cleaner.  I was going to start looking into ways to detect how many characters were after a line break, but when I tried that it turns out there weren't any.  I looked at the UILabel component and sure enough the string for that above is this:
"we would like to be able to not have the line split here"

(minus the quotes of course). 
Is there some other way that we can find out where the line break appears in the string, or is there perhaps another formatting trick we could try?  Remember this is anchored because we're supporting multiple screen resolutions and will eventually support multiple orientations as well.
Thanks!
-Mo

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel line break/formatting
« Reply #1 on: October 07, 2017, 06:19:08 AM »
NGUIText.WrapText can do the wrapping for you, inserting the new lines you're looking for.