0
votes

For example I have fixed width label with 4 word text with a fix font size. but when 4 (small )word sentence "this is my car" and other 4 (large)words sentence "elephant most beautiful animal" with same size font. so small 4 words sentence will be adjusted in fixed label width but bigger word sentence "elephant most beautiful animal" will cause the problem in that UILabel text

How can I dynamically calculate the size of sentence words and adjust font size of text to be fixed in UIlabel.

please guide...

2
paste the code what you have doneiAppDeveloper

2 Answers

0
votes
0
votes

in interface builder click on the label and set the minimum font size. if it is not in interface builder, do this

[Label setAdjustsLetterSpacingToFitWidth:YES];
[Label setMinimumScaleFactor:2];
[Label setAdjustsFontSizeToFitWidth:YES];

these shrink the font size depending on the length of the sentence. The first tightens the letter spacing and the second scales the font down by 2. The 3rd adjusts the font size.