0

I have a view controller which has a text field and label and I have set height constraint for text field and label and so I feel font size is not relative to the screen I believe.

How can I make this items' font size to be relative to the screen size?

Nicolas Miari
  • 16,006
  • 8
  • 81
  • 189
Dan Ram
  • 171
  • 1
  • 14
  • https://stackoverflow.com/questions/35153363/how-to-dynamically-change-the-font-size-in-auto-layout-ios – iPatel Sep 29 '17 at 08:15
  • Possible duplicate of [How to dynamically change the font size in auto layout iOS?](https://stackoverflow.com/questions/35153363/how-to-dynamically-change-the-font-size-in-auto-layout-ios) – Yuyutsu Sep 29 '17 at 08:17

1 Answers1

1

You can manually change UIlabel or UITextfield font in viewDidLayoutSubviews method of your ViewController or layoutSubviews method of your superView. Like this:

CGRect screenSize = [UIScreen mainScreen].bounds;
textField.font = [UIFont fontWithName:@"YourFont-Name"  
    size:screenSize.size.width/15.f];
Paul Kertscher
  • 9,416
  • 5
  • 32
  • 57