How do I add a Background Image behind a NavigatinLink

Viewed 38

I would like to have a Background Image behind a NavigatinLink but I can't seem to get the image to show. I looked everywhere on how to do this. I was able to briefly get it working using GeometryReader. However, when Xcode 14 was released it no longer was working and now I'm back to square one. I can't seem to find solution. Any help would be great, Thanks.

No Background Image Showing


    init () {
        
        UINavigationBar.appearance().largeTitleTextAttributes = [.foregroundColor: UIColor.white]
        
        UITableView.appearance().backgroundColor = .clear
                UITableViewCell.appearance().backgroundColor = .black
                UITableView.appearance().tableFooterView = UIView()    }
    
    var categories: [Category] = CategoryList.Ten
    
    var body: some View {
    NavigationView {
        VStack {
            VStack(alignment: .leading, spacing: -15) {
            List(categories, id: \.id) { category in
                NavigationLink(destination: CategoriesDetailView(category: category), label: {
                Text(category.title)
                    .fontWeight(.light)
                    .lineLimit(2)
                    .listRowBackground(Color.black)
                    .minimumScaleFactor(0.5)
                    .frame(maxWidth: 1000, minHeight: 0, alignment: .topLeading)
                    .padding(.vertical, 0)
                
                    
                }
                               
                )
                .listRowBackground(Color.black)
                .listRowSeparatorTint(.white)
                .foregroundColor(.white)
            }
                ZStack {
                    VStack {}
                .navigationTitle("Categories")
                .foregroundColor(.white)
                }
            
        }
               .background(
                GeometryReader { geo in
                          Image("Catagories-1")
                        .resizable()
                        .aspectRatio(geo.size, contentMode: .fill)
                        .edgesIgnoringSafeArea(.all)
                        .padding(.vertical, 10)
                  }

        )
        }
    }.accentColor(.white)
    }
struct CategoriesListView_Previews: PreviewProvider {
    static var previews: some View {
        CategoriesListView()
            
    }
}
}

This is a screenshot of what it looked like before the update. Before Update

This is the image I want to use as background. Background Image

0 Answers
Related