I want to set a image header for list in swiftui. The effect I want is shown in the figure below:
However, I can not remove padding in this image row. My code is as bellow:
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
List {
Section() {
Image("HeadImage")
.resizable()
.frame(height: 150)
}
ForEach((0..<4), id: \.self) { index in
Section {
NavigationLink(destination: Text("aaa")) {
Label("Buttons", systemImage: "capsule")
}
NavigationLink(destination: Text("aaa")) {
Label("Colors", systemImage: "paintpalette")
}
NavigationLink(destination: Text("aaa")) {
Label("Controls", systemImage: "slider.horizontal.3")
}
}
}
}
.navigationBarTitle("SwiftUI")
.navigationBarTitleDisplayMode(.inline)
}
.accentColor(.accentColor)
}
}
But the image row has a padding as bellow:
Is there any method to remove this padding?
It is row insets, they can be turned off as below
Section() {
Image("HeadImage")
.resizable()
.frame(height: 150)
.listRowInsets(EdgeInsets()) // << here !!
}
Tested with Xcode 14 / iOS 16