I have a similar problem. The original looks something like this:
#Preview {
struct AllCurrencyFormatInputPreview: View {
var body: some View {
VStack {
...
}
Text(...)
...
}
}
struct TopicsPreview: View {
var body: some View {
NavigationStack {
List {
NavigationLink("Currency",
destination: AllCurrencyFormatInputPreview().navigationTitle("Currency"))
}
}
}
}
return TopicsPreview()
}
The target view goes beyond the navigation bar. My work around is wrapping the content of AllCurrencyFormatInputPreview with a ScrollView. That solves my problem.
struct AllCurrencyFormatInputPreview: View {
var body: some View {
ScrollView {
VStack {
...
}
Text(...)
...
}
}
}
Post
Replies
Boosts
Views
Activity
I'm using XCode 15.0.1 (Swift 5.9)
I tried other TextField formats (ParseableFormatStyle). I couldn't get them to work except USD currency. According to Apple's documentation, it is a "Beta Software". Why is it in the production version?
For the .percent format, I think the TextField is expecting a binding variable with a Decimal type. However, I can't even declare a simple Decimal type variable. Here is an example
private var pct2: Decimal = Decimal(1)
XCode shows an "Argument passed to call that takes no arguments". That's strange. According to Apple's documentation, Decimal should have an Int initializer.
If the TextField format property is a functional feature, perhaps the documentation should provide more information and examples.
I ended up using the TextField formatter property with a NumberFormatter. for all number input, such as percent, currency, and number. I haven't type of Formatter yet. Just like @Hean20, I put the currency symbol and percentage sign outside the TextField.