Thursday 6 October 2011

Resize font when text is too long

If you are looking to resize the font when the text over flows the given area, here is a code snippet that may help.

Example is to fit a label into a given height.

On arrange check the height of the label then create a loop to reduce the font size until it fits.



while (bodyLabel.height > (image.y - bodyLabel.y)) 
{
   bodyLabel.size = bodyLabel.size - 1;
  bodyLabel.arrange();
}

No comments:

Post a Comment