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 {
Spacer()
TextField("Please type your comments here", text: $inputText, axis: .vertical)
.textFieldStyle(.roundedBorder)
.lineLimit(5, reservesSpace: true)
.padding()
Spacer()
}
}
}