简体   繁体   English

如何删除 NavigationLinks 中的背景?

[英]How to remove the background in NavigationLinks?

How do I remove the background color of navigation link(The gray stuff).如何删除导航链接的背景颜色(灰色的东西)。 在此处输入图像描述 I have tried setting the background color to clear, but that does not seem to do anything:我尝试将背景颜色设置为清除,但这似乎没有任何作用:

struct DesignView: View {

@State var index: Int
@State var selection: Int


var body: some View {
    ZStack(alignment: .center){
        RoundedRectangle(cornerRadius: 90.0)
            .fill(Color.white)
            .frame(height: 50)
        
        NavigationLink(
                destination: GraphView(type: selection, index: index),
                label: {
                    Text("Warm Up #\(index)")
                        .font(.system(size: 20, weight: .bold, design: .rounded))
                        .foregroundColor(.black)
                        .backgroundStyle(
                            Color.clear
                        )
                })
        .backgroundStyle(
            Color.clear
        )
   
        .padding()
    }
}
}

I found the solution:我找到了解决方案:

Navigation Links respond to tint, not to the bcgrnd color for that purpose:导航链接响应色调,而不是为此目的的 bcgrnd 颜色:

NavigationLink(
                destination: GraphView(type: selection, index: index),
                label: {
                    Text("Warm Up #\(index)")
                        .font(.system(size: 20, weight: .bold, design: .rounded))
                        .foregroundColor(.black)
                        .backgroundStyle(
                            Color.clear
                        )
                })
        .tint(Color.clear)
        .backgroundStyle(
            Color.clear
            
        )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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