Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different font size for UILabel using adaptive layout

In Xcode 6 we have a new feature called adaptive layout. By using that I have created a new project in which it I need to have different font size based on the layout.

In iPhone 3.5 inch screen I must have font size as 17pt, and other screen size in iPhone must be 21pt.

Can anyone tell me how I can achieve this using adaptive layout?

like image 416
Arasuvel Avatar asked Oct 07 '14 12:10

Arasuvel


People also ask

How do you change the font size on UILabel?

To change the font or the size of a UILabel in a Storyboard or . XIB file, open it in the interface builder. Select the label and then open up the Attribute Inspector (CMD + Option + 5). Select the button on the font box and then you can change your text size or font.

How do I change dynamic font size in Swift?

In Interface Builder, select the text style from the Font menu, then select the Automatically Adjust Font checkbox to the right of Dynamic Type.

What is Dynamic Type on iphone?

February 11, 2021. The Dynamic Type feature allows users to choose the size of textual content displayed on the screen. It helps users who need larger text for better readability. It also accommodates those who can read smaller text, allowing more information to appear on the screen.


2 Answers

Yes, you can do with storyboad. There is a + sign on the left of the font, click it and select the size class and choose the font size needed

like image 126
Oscar Bui Avatar answered Oct 16 '22 17:10

Oscar Bui


In viewDidAppear or viewWillAppear, you can detect the size of the layout. You only have to update font size based on the detected size.
You can use [[UIScreen mainScreen] bounds]; or in iOS8 : [[UIScreen mainScreen] nativeBounds];

like image 41
David 'mArm' Ansermot Avatar answered Oct 16 '22 18:10

David 'mArm' Ansermot