How to turn off NavigationLink overlay color in SwiftUI?

后端 未结 2 1162
花落未央
花落未央 2021-02-19 01:22

I\'ve designed a \"CardView\" using ZStack in which the background layer is a gradient and the foreground layer is a PNG(or PDF) image(the image is a yellow path(like a circle)

相关标签:
2条回答
  • 2021-02-19 01:59

    The navigationLink acts like Button and it gets the default button style with blue color.

    Using .renderingMode(.original) works only on Image views. what if you decide to load your Image using some libs or pods?!

    It is better to change the default button style to plain using the bellow modifier:

    NavigationLink(destination: Text("Hello")) {
                ZStack {
                    RoundedRectangle(cornerRadius: cRadius)
                        .foregroundColor(.white)
                        .opacity(0)
                        .background(LinearGradient(gradient: Gradient(colors: [Color(red: 109/255, green: 58/255, blue: 242/255),Color(red: 57/255, green: 23/255, blue: 189/255)]), startPoint: .leading, endPoint: .trailing), cornerRadius: 0)
                        .cornerRadius(cRadius)
                        .frame(height: cHeight)
                        .padding()
                    Image("someColoredPathPNGimage")
                }
            }
            .buttonStyle(PlainButtonStyle())  /*Here, is what you need*/
    
    0 讨论(0)
  • 2021-02-19 02:10

    Try:

    Image("someColoredPathPNGimage").renderingMode(.original)
    

    If your problems continue, consider uploading a screenshot so we get an idea of what you mean. If you can include the image you are using, even better, so we can replicate.

    0 讨论(0)
提交回复
热议问题