Post

Replies

Boosts

Views

Activity

Why is TextField height wrong when changing font size?
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?
3
0
3.2k
Nov ’19
How to remove SwiftUI TextField focus border?
How does one remove the focus border for a TextField in SwiftUI?In Cocoa, setting the border to "None" in interface builder would remove the border.I've tried using .border with a width of zero, but that does not work. The .border adds another border on top of the focus border.Setting the style also does not do the trick.
2
0
4.7k
Oct ’19