简体   繁体   中英

SwiftUI hide the arrow in NavigationLink

Very simple question, I searched the whole world about how to hide the damn arrow in NavigationLink but none of the even close. 在此处输入图片说明

NavigationLink(destination: NewKnock()) {
                    Image("knock_hand_icon").resizable().frame(width: 40, height: 40).padding(3)
                    }.fixedSize()

I believe it's just add some modifiers or so. Thanks

Be creative. You can use ZStack with an EmptyView to achieve that. Something like:

ZStack {
    Image("knock_hand_icon").resizable().frame(width: 40, height: 40).padding(3)
    NavigationLink(destination: NewKnock()) {
        EmptyView()
    }.fixedSize()
}

As of now there does not appear to be an official way to address this. I would assume a lot of these customizations will come in future versions of SwiftUI. That being said my work around is to place the content on a very high zIndex and adjust padding to move the content over the arrow.

NavigationLink(destination: NewKnock()) {
  Image("knock_hand_icon")
    .resizable()
    .frame(width: 40, height: 40)
    .padding(3)
    .zIndex(999999)
    .padding(.trailing, -16)
}

You'll have to play with it a bit, but the .trailing padding of -16 moves the image over the arrow coupled with the zIndex that will ensure it is above the arrow.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM