6

In SwiftUI I'm trying to get my TextEditor content into leading alignment with the Text above it. I have a pattern to do this in UIKit but can't seem to find the correct modifiers in SwiftUI.

In the attached screenshot, I'd like the text origin to be (0,0). Not... (6, 12), roughly.

enter image description here

Implementation Code:

struct AttributedTraitField: View {
    let name: String
    @State private var value: String = "Placeholder"
    var body: some View {
        VStack(alignment: .leading, spacing: 0.0) {
            Text(name)
                .background(Color.blue)
            TextEditor(text: $value)
        }
        .padding(.all)
        .background(Color.green)
    }
}
  • You cannot influence the inset of TextEditor. You could shift the whole thing e.g. using .offset but I suppose that is not what you want. – ChrisR Feb 06 '22 at 16:07

0 Answers0