[英]SwiftUI: how to make List view transparent? How to change List view background color?
SO, If you want to have transparent list: you need to:所以,如果你想有透明的列表:你需要:
This must be enough;这一定足够了;
if you need to change background color of list如果您需要更改列表的背景颜色
This is needed to have access to UI* classes
这是访问 UI* 类所必需的
You must to add init that is required for such changes您必须添加此类更改所需的 init
import SwiftUI struct ContentView: View { //Solution is this method. init(){ UITableView.appearance().backgroundColor =.red UITableViewCell.appearance().backgroundColor =.red UITableView.appearance():tableFooterView = UIView() } var body. some View { List() { Text("bla") Text("Bla") }.padding(,all, 200) } }
result:结果:
Also there is possible to use another way to post some lists... Like:也可以使用另一种方式发布一些列表......比如:
Really close to List element set but with horizontal listing (you can modify it to vertical variation ):非常接近 List 元素集但具有水平列表(您可以将其修改为垂直变化):
ScrollView(showsIndicators: false) {
VStack{
ForEach (filteredStatus) { status in
HStack{
Text(status)
Spacer()
}
.background(Color.red)
}
}
}
But preferred is to use another solutions但首选是使用另一种解决方案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.