How to stop SwiftUI from changing font sizes automatically

1.9k Views Asked by At

I using text like this in SwiftUI

Text("Customize").font(.footnote)

But this is also changing the font size base of device font size settings.

So how I stop SwiftUI to change the default font size automatically?

PS: I don't want to set all Texts font size manually.

2

There are 2 best solutions below

0
On

Just create a Font extension like this:

import SwiftUI

extension Font {
    static var appButton:Font {
        get {
            return .system(size: 18)
        }
    }
}

Then use it as:

Text("Observation mode")
.font(.appButton)
2
On

Hey! Please Give It A Try!

Text("Customize").font(.system(size: 32))