TextEditor
似乎有默认的白色背景.因此,以下内容不起作用,它显示为white
,而不是定义的red
:
var body: some View {
TextEditor(text: .constant("Placeholder"))
.background(Color.red)
}
可以把 colored颜色 改成定制的吗?
TextEditor
似乎有默认的白色背景.因此,以下内容不起作用,它显示为white
,而不是定义的red
:
var body: some View {
TextEditor(text: .constant("Placeholder"))
.background(Color.red)
}
可以把 colored颜色 改成定制的吗?
TextEditor
由UITextView
支持.所以你需要先go 掉UITextView
的backgroundColor
,然后你可以把View
设置成background
.
struct ContentView: View {
init() {
UITextView.appearance().backgroundColor = .clear
}
var body: some View {
List {
TextEditor(text: .constant("Placeholder"))
.background(Color.red)
}
}
}
你可以找到我增加TextEditor here in this answer的简单技巧