【发布时间】:2020-09-29 07:32:36
【问题描述】:
我想将视图背景颜色设置为绿色。我有一个列表视图,它很好,但底层视图需要是绿色的——参见图像。我知道我遗漏了一些东西,但使用 SwiftUI,你有时不知道它是一个错误还是它应该如何工作。我将不胜感激任何对其他人有用的想法。我已附上我的代码,并且我使用的是 Xcode 版本 11.5 (11E608c)。
代码如下:
var body: some View {
ZStack() {
Color(red: 95.0/255.0, green: 122.0/255.0, blue: 128.0/255)
.edgesIgnoringSafeArea(.all)
Text("")
List {
Group {
Text("Price: ")
Text("Down: ")
Text("APR: ")
Text("Term: ")
Text("Tax: ")
Text("Rebate: ")
}.listRowBackground(Color(red: 95.0/255.0, green: 122.0/255.0, blue: 128.0/255))
Group {
Text("Add On: ")
Text("Fees: ")
Text("Trade Value: ")
Text("Total Interest: ")
Text("Payment: ")
}.listRowBackground(Color(red: 95.0/255.0, green: 122.0/255.0, blue: 128.0/255))
}
}
}
【问题讨论】:
-
参考这个 SO 答案:stackoverflow.com/questions/56517904/…
标签: list background swiftui zstack