1

I am creating a screen using a Form, with one TextField and one textEditor. Here is my code:

struct AddIssueView: View {

    @State var title = ""
    @State var description = "Enter issue description"

    var body: some View {
    
        NavigationView {
            Form {
                 Section(header: Text("Title")) {
                    TextField("Enter issue title", text: $title)
                 }
                
                 Section(header: Text("Description")) {
                    TextEditor(text: $description)
                 }
                 .navigationTitle("New Issue")
            
            }
        
        }
    
    }
}

This is the resulting screen - I find it surprising that the TextEditor UI looks like the TextField UI - I expected to see a multi-line text area. I'm not sure what I'm missing - any help will be most appreciated.

enter image description here

  • 4
    It looks like when using a Form/ List or ScrollView, SwiftUI automatically inferred the height for your `TextEditor`, to fix that you can give a height to your `TextEditor` – cedricbahirwe Jul 22 '21 at 14:23

1 Answers1

0

Set the frame size on the TextEditor. Here are values I'm using in a project. Fiddle around with the values to get the size you'd like.

TextEditor(text: $postBody)
    .frame(minWidth: 200,
           idealWidth: 250,
           maxWidth: 400,
           minHeight: 300,
           idealHeight: 325,
           maxHeight: .infinity,
           alignment: .center)
Gene De Lisa
  • 3,628
  • 1
  • 21
  • 36