Hi,
How to hide the Chevron icon from a list rows in SwiftUI ?
Kindest Regards
Hi,
How to hide the Chevron icon from a list rows in SwiftUI ?
Kindest Regards
Since ZStack
stacks views on top of each other you can take advantage of that! Place a Text
view on top of NavigationLink
and replace Text
view in the body of NavigationLink
with an EmptyView
List(items, id: \.self) { item in
ZStack(alignment: .leading) {
Text(item.name)
NavigationLink(destination: Text(item.name)) {
EmptyView()
}
.opacity(0.0)
}
}
Here is a way to mimic a List without chevron, with a ScrollView:
ScrollView(.vertical, showsIndicators: true) {
ForEach(0..<15) { index in
HStack {
Spacer()
NavigationLink(destination: DestinationView(item: index)) {
Text("Navigate \(index) to View 1")
}
// Text(">") // This would mimic a List's chevron
Spacer()
}
.padding(.vertical, 5)
}
}
.navigationBarTitle("Navigation Links")
}
}
}
struct DestinationView: View {
var item: Int
var body: some View {
Text("Destination View for item \(item)")
.navigationBarTitle("View", displayMode: .inline)
}
}
ForEach (patients) { patient in
NavigationLink (value: patient) {
PatientRow(patient: patient)
}
}
.onDelete(perform: deletePatient)
.listRowSeparator(.hidden)
}
.listStyle(.plain)
.buttonStyle(PlainButtonStyle())
.scrollIndicators(.hidden)
.navigationDestination(for: Patient.self) { patient in
PatientDetails(patient: patient)
}
Above the foreach there's a line of code "List {" don't know why Apple editor cut it, the code formatting is very bad by the way.