我知道如何更改 SwiftUI 视图列表的背景颜色,但我找不到默认颜色。我尝试过使用 MacOS 的“数字色度计”,但它无法正确识别颜色。
正如您在此图中看到的,我尝试设置列表行的背景颜色(使用.listRowBackground
根据数字色度计的值与周围列表完全相同。
有人真的知道默认背景颜色实际上是什么吗?
简短回答:看起来像是 UIColor.secondarySystemBackground
长答案:
我努力了数字色差计像你一样应用程序。它显示 RGB 值:242、242、247。
I have created such color:
这是我的代码:
import SwiftUI
extension Color {
public static let ListBGColor = Color("ListBGColor")
}
struct ContentView: View {
var body: some View {
List {
ForEach(0..<5) {_ in
Text("Hello, world!")
.padding()
}
.listRowBackground(Color.ListBGColor)
}
.listStyle(InsetGroupedListStyle())
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Result: the same color as the background (testes on Simulator and iPhone):
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)