How to use a custom font with dynamic text sizes in iOS7

前端 未结 12 2111
长情又很酷
长情又很酷 2020-11-29 14:41

In iOS7 there are new API\'s for getting a font that is automatically adjusted to the text size the user has set in their preferences.

It looks something like this to

12条回答
  •  北荒
    北荒 (楼主)
    2020-11-29 15:30

    In iOS 11 you can use:

    var customFont = UIFont.systemFont(ofSize: 17.0)
    if #available(iOS 11.0, *) {
        customFont = UIFontMetrics.default.scaledFont(for: customFont)
    }
    // use customFont...
    

    See also Building Apps with Dynamic Type WWDC 2017 - Session 245 - iOS time 8:34.

提交回复
热议问题