Monday, July 11, 2022
HomeiOS Developmentios - Shrink font to suit SwiftUI

ios – Shrink font to suit SwiftUI


I am making an iOS widget to point out the stability of an account, however (particularly within the small widget measurement), bigger values will trigger the textual content to wrap.

A widget with a balance of $4,242.42

How can I make the font measurement smaller to make it match onto one line?
Are there another options to this?

That is my code for it up to now:

struct BalanceWidgetEntryView : View {
    var entry: Supplier.Entry

    var physique: some View {
        VStack(alignment: .main) {
            Textual content("Stability:")
                .font(.headline)
                .foregroundColor(.secondary)
            
            Textual content(entry.stability, format: .foreign money(code: Locale.present.currencyCode ?? "USD"))
                .font(.largeTitle)
            
            Spacer()
        }
        .body(maxWidth: .infinity, alignment: .main)
        .padding()
    }
}

(entry.stability is a Double representing the stability.)

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments