I have a simple SwiftUI view with a TextField in a macOS app. I change the font size of the TextField.
The TextField keeps its original height (prior to changing the font) until it has text, when it suddeny jumps to the correct size.
One work around is to have placeholder text (even an empty string with just a space in it), but then the cursor looks funny as the cursor keeps the original height.
The following code shows the problem:
struct ContentView: View {
@State var input: String = ""
var body: some View {
TextField("Type Here", text: $input)
.font(Font.custom("Arial", size: 35))
}
}
I've tried changing the height (using frame modifier) of my view, but this shows the smaller TextField in the larger view, until the TextField receives input.
Is this a bug in TextField, or am I doing something wrong and either way, does anybody have a workaround/fix for it?