How to make Multiline TextField in iOS SwiftUI

iOS 16

You can use .lineLimit(5, reservesSpace: true) where first argument denotes the lines required & reservesSpace means do you need default space for `n` lines. If you make it false by default single line space will be shown.
Just Like A UITextField in UIKit it works as a multiline text entry in iOS application.

struct ContentView: View {
    @State var inputText: String = ""
    var body: some View {
        VStack {
            TextField("Please type your comments here", text: $inputText, axis: .vertical)
                .lineLimit(5, reservesSpace: true)

Leave a Comment

Your email address will not be published. Required fields are marked *