问题是 .background()
修饰符在不同主题上的工作。
完全相同的代码对两个主题有不同的效果:
我这边有问题还是这是 swiftUI 的错误?
TextField("Any text", text: $anyText)
.background(Color.red)
最佳答案
深色模式的人机界面指南部分内容如下:
Use the system-provided label colors for labels. The primary, secondary, tertiary, and quaternary label colors adapt automatically to light and dark appearances. For related guidance, see Typography.
https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/dark-mode/
尝试为文本设置 .secondary() 颜色
关于SwiftUI 如何更改 Light 主题(外观)上 TextField 的背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58979193/