Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing UILabel font size with AutoLayout

I'm working with Swift, IOS 8 and AutoLayout. I have a big label, size 40 on center of the screen.

I want that on iPhone 5s- the size of label becomes like 34, and on iPad a bigger font size, like 50.

How can I do this with AutoLayout?

like image 312
Lücks Avatar asked Dec 03 '22 17:12

Lücks


2 Answers

I found a solution: Just go to your storyboard, click on your label and then click on "+" on the left of "Font" (Attributes Inspector) and add another font with a different size:

Adding multiple font's size

On my case, I added for iPad a size of 50. Worked perfectly!

like image 88
Lücks Avatar answered Dec 25 '22 09:12

Lücks


Step 1 : Select UILabel and Click on plus icon in Attribute Inspector

enter image description here

Step 2 : To add font size for new device let suppose Iphone Portrait, hover on Compact Width -> Any Height.

enter image description here

Step 3 : Now change this new font to 25 i.e for iphone. And on the Font above it to be 70 which is now for devices other than iphone portrait.

enter image description here

Step 4 : Output on iphone6 vs Ipad Retina

enter image description here

enter image description here

like image 39
person Avatar answered Dec 25 '22 10:12

person