[英]How do I make the background of a SwiftUI list transparent?
我试图使列表透明化,因此背景上只显示步数和步数。 有没有办法使灰色背景透明,并对列表单元格中的白色也做同样的事情?
CustomNavigationLink(title: "Steps (Last 7 Days)") {
List(listSteps, id: \.id) { stepList in
VStack(alignment: .leading) {
Text("\(stepList.count)")
.font(.custom(customFont, size: 40))
.fontWeight(.semibold)
Text(stepList.date, style: .date)
.opacity(0.5)
.font(.custom(customFont, size: 20))
.foregroundColor(.cyan)
.padding(1)
}
}
.background(Image("GreenBG"))
.navigationTitle("Steps (last 7 days)")
.padding()
}
您需要的是将 VStack 的列表行背景设置为清除:
VStack(alignment: .leading) {
Text("\(stepList.count)")
.font(.custom(customFont, size: 40))
.fontWeight(.semibold)
Text(stepList.date, style: .date)
.opacity(0.5)
.font(.custom(customFont, size: 20))
.foregroundColor(.cyan)
.padding(1)
}
.listRowBackground(Color.clear)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.