I want to display a currency value in a SwiftUI app. I created a currency formatter. I created a text field, set its formatter to the currency formatter I created, and disabled the text field so people couldn't edit it.
let currencyFormatter: NumberFormatter = { let formatter = NumberFormatter() formatter.numberStyle = .currency return formatter }() TextField("Tip Amount", value: $tipAmount, formatter: currencyFormatter) .disabled(true)
This works well on iOS. The currency formatter works correctly. I can see the value clearly and can't change it. But on Mac the text in the disabled text field is virtually unreadable.
I just want to display the value so I don't need a text field. I could use a Text
view. But Text
views don't support formatters as far as I can tell.
How do I show a currency value with SwiftUI on Mac with readable text?