Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to adjust a label size to fit the length of the text

I have searched the solution to this in the past QAs, but could not find the right one.
Does anyone know how to adjust aUILabel size dynamically to fit the text length?
I have uploaded the screen shot of what I don't want(1st line) and what I want(2nd line).
I'd appreciate any clues, advice or code sample. Thank you.enter image description here

like image 809
boochan224 Avatar asked Jun 01 '13 01:06

boochan224


People also ask

How do I resize a label in Xcode?

Here's the step that work in mine: Set width constraint to the label, then click the constraint. Select Size Inspector. Set the relation to less than or equal, and set max width.


1 Answers

What you are searching is the UILabel method sizeToFit

I can try to explain to you, but the best answer to know how to work with UILabel is that: https://stackoverflow.com/a/1054681/666479

like image 84
ggrana Avatar answered Sep 22 '22 04:09

ggrana