Is it possible to render a multiline TextField in SwiftUI?

I've been trying to do this without success, and just wondered if it was currently impossible.

Replies

Option-Click your Text declaration, select inspector and set the number of lines you want.

This has no effect, I'm afraid. I think you might be referring to a Text object, not a TextField.


The TextField takes dynamic content, therefore the length of user input is unknown at runtime.


It seems no-one can get multiline TextFields to work without writing a custom wrapper for UITextView.

Agreed, seems crazy but from what I'm seeing online that's the only way to do it. Tried using .frame to modify the size, linelimit with various Ints, and multiline text alignment set to leading, all with no effect. The only other thing i could think of doing would be to create a custom view which dynamically generates TextFields as and when they're required in something like a list or VStack, but I haven't had the time to try this yet.