在新版本xcode Version 12.5.1 (12E507)中
通过init()去除List的某些样式已经无效
故采用ScrollView+LazyVStack来代替List
通过navigationBarHidden来隐藏顶部的navigationBar区域
var body: some View {
NavigationView{
ScrollView(showsIndicators: false){
LazyVStack{
ForEach(postList.list) { post in
NavigationLink(destination: PostDetailView(post: post)) {
PostCell(post: post)
.padding()
}
.navigationBarHidden(true)//去除顶部bar区域
.accentColor(.black)//去除NavigationView的字体样式
.buttonStyle(StaticButtonStyle())//去除NavigationView的点击效果
}
}
}
}
}
struct StaticButtonStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
configuration.label
}
}