Search code examples
swiftswiftuiswiftui-navigationlink

How to remove the default forward icon from navigationlink in swift ui


List {
  Section {
    NavigationLink(destination: changePassword(oldPassword: $password)) {
      HStack {
        Text("Şifreyi Değiştir")
        Spacer()
        Image(systemName: "chevron.right")
      }
    }
    .foregroundColor(.orange)

    Button(action: {
      self.showingDeleteAccountPopup = true
    }) {
      HStack {
        Text("Hesabı Sil")
        Spacer()
        Image(systemName: "chevron.right")
      }
    }
  }
}

enter image description here

how can I remove the default icon from the navigation link in the change password section

I have two buttons, change password and delete account. but one is Button and the other is NavigationLink, the icons look different because of this difference. i want to use the same icon in both places. how do i remove the default icon from the navigation link in that section?


Solution

  • This seems to work, just replace the NavigationLink with this:

    HStack {
        Text("Şifreyi Değiştir")
        Spacer()
        Image(systemName: "chevron.right")                 
    }
    .foregroundColor(.orange)
    .overlay {
        NavigationLink(destination: {changePassword( oldPassword : $password ) }, label: { EmptyView() })
            .opacity(0)
    }
    

    (Code based on link)