0

With UIKit, is there a recommended way to make font size work well with all device sizes other than having to customize/hard code the font sizes for each specific device?

user1615898
  • 1,185
  • 1
  • 10
  • 20
  • Your goal is unclear. What exactly do you wish to happen on different devices? Why would the font change? – rmaddy Mar 23 '17 at 03:13
  • Because lets say I want to make a heading for a view controller with font 20, that may look OK with an iPhone SE, but it could look too small relative to the screen with an iPad Pro. – user1615898 Mar 23 '17 at 03:15
  • 1
    Not necessarily. When I use an app on a larger physical screen, I hope to see more information, not the same amount of information in a larger font. That's a complete waste of the bigger screen. – rmaddy Mar 23 '17 at 03:18
  • 2
    You really shouldn't *dictate* font size if possible. Do a search on "dynamic type iOS" and spend an hour learning to let the user choose what they want. Beyond that, just make sure you use auto layout with an understanding of intrinsic size. –  Mar 23 '17 at 03:33
  • If you want to make the font sizes for all different sizes (and, yes, I agree, that you sometimes do want different fonts for different devices), that doesn't mean you have to set up a different font for _every_ unique device. You might set up different fonts for different size classes, for example, one for compact width and another for regular width. – Rob Mar 23 '17 at 07:13
  • FYI, WWDC 2016 video, [Making Apps Adaptive, Part 1](https://developer.apple.com/videos/play/wwdc2016/222/), illustrates precisely this. – Rob Mar 23 '17 at 07:26

2 Answers2

2

You could set a maximum and minimum font scale in the storyboard or in your view controller. Depending on your audience it's best not to go below 8 or 9pt font size. Also make sure your FontSizeToFitWidth is set to true so it will auto shrink.

bach942
  • 77
  • 1
  • 9
1

Super general question but rather than ignore it I'll try to answer what I think you're asking:

Generally speaking, I try to find the happy medium, a font size that'll look ok for all devices (iPhone, iPod Touch etc. iPad is obviously a different animal). If you are looking to launch something for both iPhone and iPad then I would suggest looking at this answer. It has some details as to how you can create different storyboards for different devices in your AppDelegate.swift

Community
  • 1
  • 1
bananibau5
  • 174
  • 2
  • 10