TextEditor
seems to have a default white background. So the following is not working and it displayed as white
instead of defined red
:
TextEditor
is backed by UITextView
. So you need to get rid of the UITextView
's backgroundColor
first and then you can set any View
to the background
.
struct ContentView: View {
init() {
UITextView.appearance().backgroundColor = .clear
}
var body: some View {
TextEditor(text: .constant("Placeholder"))
.background(Color.red)
}
}