Home > Enterprise >  Rounded font design with dynamic scaling in iOS 15
Rounded font design with dynamic scaling in iOS 15

Time:01-10

I'm trying to use a rounded font design, with dynamic fonts. I am targeting iOS 15 .

I cannot use this, as it's iOS 16 :

Text("Hello")
    .font(.system(.body, design: .rounded, weight: .bold))

This says Font.Design is available for iOS 13 , but I can't work out how to use it. I added .fontDesign(.rounded), but it says this is iOS 16 only. I can't find any example syntax using rounded with dynamic fonts (that works on iOS 15). I have scrolled through the list of suggested syntax, and tried inserting design parameter in various places... no luck.

This is what I was previously using for rounded font design, but this uses a fixed size font, which does not scale:

Text("Hello")
    .font(.system(size: 16, weight: .medium, design: .rounded))

This works, but I want more control over the font size (e.g. not restricted to the preset title, headline, etc:

Text("Hello")
    .font(.system(.headline, design: .rounded))
    .fontWeight(.bold)

CodePudding user response:

You are asking for something that isn't possible. You can either specify a font size or you can use dynamic type. Dynamic type requires that you use text styles:

Scaling Fonts Automatically

To add support for Dynamic Type in your app, you use text styles. A text style describes the use of the text, such as headline or body or title1, and lets the system know how best to adjust its size. You can configure text styles in either Interface Builder or your source code.

Your code in the "this works" block is exactly how you combine the rounded design with dynamic type.

  • Related