1
votes

I have a UILabel inside a UIView and I want the label to be resized proportionally as the UIView is resize. I was able to do so with a UIImageView but the label stays as big as I placed it in IB.

I have set the view contentMode to UIViewContentModeScaleAspectFit thinking that anything inside the UIView would be "aspect fit" but I had to set the same mode to the UIImageView (which works fine) and I can't set that mode to the UILabel.

Thanks for your help.

2
Is it the label you want to resize or the text displayed in the label ?VdesmedT
Well... I want the label to have the same proportional size inside the UIView... so the text would go bigger and tinier as the view size changes.DEIONaLiMs

2 Answers

1
votes

It appears CGAffineTransform is the answer.

myView.transform = CGAffineTransformMakeScale(0.5, 0.5);

This would resize the view and everything that is inside dividing the view width and height by 2.

0
votes

set setAutoresizingMask of label