zl程序教程

您现在的位置是:首页 >  其它

当前栏目

SwiftUI Swift 问答之SwiftUI设置节标题高度?

设置 swift SwiftUI 高度 标题 问答
2023-09-11 14:18:30 时间

实战问题

我有一个清单:

    List {
        
        ForEach(model.sections) { s in

            Section(header: SectionView()) {
             
                ForEach(items, id: \.self) { item in
                    Text(item.name)
                        .border(Color.mint)
                }
                
            }

        }
        
    }
    
    .listStyle(.plain)

我有SectionView我想为节标题构建的视图:

struct SectionView: View {
    
    var body: some View {
        GeometryReader { geo in
            
            HStack {
                
                Text("Section Header View")
                    .frame(width: geo.size.width, height: 60)
                
                
            }
            .frame(maxWidth: .infinity, maxHeight: .infinity)
            .border(Color.green)
        }
        
    }
    
}

不幸的SectionView是,标题中的内容现在在单元格上流血了。实际的节标题高度没有改变。如何设置自定义节标题高度&