Reputation: 3008
In the following code, why does the frame of the TextEditor stay within the safe area, while the text is pushed up to the top of the screen, beyond the safe area, and outside of the TextEditor's frame?
VStack {
TextEditor(text: $myText)
.frame(height: 200)
.border(Color.red)
Spacer()
}
Upvotes: 3
Views: 897
Reputation: 18904
You have to use .padding()
to adjust the text frame.
Adding padding is like adding textContainerInset
in UITextView.
Like this
struct TestFrameView: View {
@State private var myText: String = "Hello"
var body: some View {
VStack {
TextEditor(text: $myText)
.padding() //<-- here or .padding(.top, 0.1) for zero space.
.frame(height: 200)
.border(Color.red)
Spacer()
}
}
}
Upvotes: 4