I have a issue about NavigationLink
in SwiftUI. I have a List
restaurant and have NavigationLink
in it. I tried to remove the caret right in right of NavigationLink section but not success
I tried to remove caret using buttonStyle
but is's not work.
List(vm.restaurants) { (restaurant: Restaurant) in
NavigationLink(destination: ResDetailView(restaurant: restaurant)) {
RestaurantRow(life: life)
}.buttonStyle(PlainButtonStyle())
}
Chris' answer works, but EmptyView
has a height which adds empty space to the bottom of the cell. Instead, you can use ZStack
to make the navigation link on top of the cell.
List {
ForEach(0..<items.count) { i in
ZStack {
ContactRow(item: self.items[i])
NavigationLink(destination: ChatView()) {
EmptyView()
}
}
}
}
you can do it like this:
var body: some View {
NavigationView() {
List(menu, id: \.self) { section in
VStack{
Text(section.name)
NavigationLink(destination: Dest()) {
EmptyView()
}
}
}
}
The easiest way to get rid of the disclosure indicator is to set the padding on the NaviagtionLink:
NavigationView {
List {
ForEach(items) { item in
NavigationLink(destination: Destination(item: item)) {
CustomCell(item: item)
} .padding([.trailing], -30.0)
}
}
}
I wouldn't recommend it though - it's a way of showing your users that there is more data available if the tap on one of the cells.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.