I have a text field and I have given it a regular font with 13 px in size.
But I want the font size to increment with respect to screen size.
Thanks.
You can calculate the font size based on the screen's dimensions.
let baseWidth: CGFloat = 320 // the width of the screen where you want to use 13pt
let fontSize = 13 * (UIScreen.main.size.width / baseWidth)
let font = UIFont(name: "HelveticaNeue", size: fontSize)
You can simply do this by checking, Automatically Adjusts Font
in the Attributes Inspector
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With