I wanted the TextEditor
to display eg. three lines of text. I have some sample code like this:
import SwiftUI
struct MultiLineText: View {
@State var value: String
@State var text: String
var body: some View {
Form {
TextField("Title", text: $value)
TextEditor(text: $text)
}
}
}
struct MultiLineText_Previews: PreviewProvider {
static var previews: some View {
MultiLineText(value: "my title", text: "some text")
}
}
The problem is, that I always see only one line at a time for both controls (TextEditor
and TextField
) although I would like to have multiple lines displayed for the TextEditor
.
How to realise this?