SwiftUI-navigationBarItems-背景变为灰色

问题描述

每当我在导航视图中添加.navigationBarItems时-背景就会从白色变为灰色。列表项仍为白色,但是为什么变为灰色?另外,我如何确保背景保持白色?

下面是我的代码:

var body: some View {
        
  
        NavigationView {
            
            List{
                ForEach(self.store.updates) { update in
                    NavigationLink(destination: UpdateDetail(update: update)) {
                        HStack {
                            Image(update.image)
                                .resizable()
                                .aspectRatio(contentMode: .fit)
                                .frame(width: 80,height: 80)
                                .background(Color.black)
                                .cornerRadius(20)
                                .padding(.trailing,4)
                        
                            VStack(alignment: .leading,spacing: 8.0) {
                                
                                Text(update.title)
                                    .font(.system(size: 20,weight: .bold))
                                
                                Text(update.text)
                                    .lineLimit(2)
                                    .font(.subheadline)
                                    .foregroundColor(Color(#colorLiteral(red: 0.501960814,green: 0.501960814,blue: 0.501960814,alpha: 1)))
                                
                                Text(update.date)
                                    .font(.caption)
                                    .fontWeight(.bold)
                                    .foregroundColor(.secondary)
                            }
                        }
                        .padding(.vertical,8)
                    }
                    
                    
                }
            }
            .navigationBarTitle(Text("Large Title"))
            .navigationBarItems(leading: Button(action: addUpdate) {
                Text("Add Update")
            })
            
            
        }

    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)