Tuesday, 6 August 2013

set label with dynamic height and fixed width

set label with dynamic height and fixed width

Hello I can't find a straight answer for this so I decided to post my
question. I have a Label in the middle of my screen with text on it. I
want the width of the label to remain fixed and only the height to change
when the text gets longer or shorter. Right now both are dynamically
changing according to my text length. Here's my code..
[label setFrame:CGRectMake(16, 180.0, 291.0, 30)];
label.numberOfLines = 0;
[label sizeToFit];
[self.view addSubview:label];
Thanks

No comments:

Post a Comment