-1

is it possible to set the width of SwiftUI TextField to hold a certain number of characters and display them without cutting them off? This way the width would adjust automatically based on font size.

The .frame(width/minWidth/maxWidth) is not really useful in this sense unless I would calculate the size of the characters.

Thanks for any ideas. Libor

matyasl
  • 295
  • 2
  • 11
  • You could adjust the strategy here to change width instead of height: https://stackoverflow.com/a/69002976/560942 – jnpdx Jan 26 '22 at 19:00

1 Answers1

1

I may have found a solution and that is TextField(....) .fixedSize(horizontal: true, vertical: true)

matyasl
  • 295
  • 2
  • 11