代码之家  ›  专栏  ›  技术社区  ›  Sage

有没有办法在顶部使用NavigationView获得渐变背景

  •  0
  • Sage  · 技术社区  · 3 年前

    This is what it looks like now This is the code 问题是它在NavigationView下面没有显示任何类型的渐变。

    I tried putting the gradient like this and this 。如果你想知道为什么没有太多代码,那是因为我刚刚启动了这个应用程序。

    0 回复  |  直到 3 年前
        1
  •  0
  •   bennyyy999    3 年前

    我认为你的订单是错误的,有 NavigationView 在顶部,使其工作。

    NavigationView {
        ZStack {
            LinearGradient (gradient: Gradient(colors: [Color.red, Color.blue]), startPoint: .top, endPoint: .bottom)
                    .ignoresSafeArea()
                    
            NavigationLink(destination: CreateCustomLevelView(), label: {
                Text ("Create New")
                    .padding (15)
                    .background (Color.blue)
                    .foregroundColor (Color.black)
                    .cornerRadius (15)
                })
            }
        }