[英]Background color not change TextEditor view
//.........some other views........
ZStack(alignment: .leading ) {
Color.black.ignoresSafeArea()
TextEditor(text: $mytext)
.background(Color.orange)
.padding()
.foregroundColor(Color.gray)
.frame(width: 362, height: 400)
}
對於我應用的所有情況,背景顏色仍然是 Color.white,所以這里有什么問題? 謝謝你。
你不能真正改變SwiftUI TextEditor的background
。 任何一種材質/形狀/顏色都不能用作 SwiftUI TextEditor 的背景。
但是,您可以將 TextEditor 的顏色相乘,這提供了與一般背景(.color)相似的結果,但它並不是真正的背景顏色。
TextEditor(text: $mytext)
.colorMultiply(.orange) //modified
.padding()
.foregroundColor(Color.gray)
.frame(width: 362, height: 400)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.