Line spacing in SwiftUI TextEditor

Am I not supposed to use .lineSpacing with a SwiftUI TextEditor? When I try, the up and down arrow keys get all messed up. Even a simple one like this:

struct ContentView: View {
    @State private var theText = ""
    
    var body: some View {
        TextEditor(text: $theText)
            .lineSpacing(20.0)
            .frame(width: 700, height: 500 , alignment: .leading)
            .border(Color.black, width: 1)
    }
}

Left and right arrows work fine, but with up and down the cursor jumps all over the place. On long entries, scrolling gets weird. I’ve tried a bunch of different values.

Leave a Comment