[英]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.