SwiftUI List view have a different shade of color after I upgraded to Xcode 12

550 Views Asked by At

After I upgraded to Xcode 12, my List view have a different shade of white or black (depending on Light mode or Dark mode) compared to its background. But my other List view in the same app is alright. Why? Below are the screenshots and accompanying code. Please advise, thank you.

enter image description here

enter image description here

List
        {
            VStack
            {
                Picker("Numbers", selection: self.$selectorIndex)
                {
                    ForEach(0..<self.numbers.count)
                    {
                        index in Text(self.numbers[index]).tag(index)
                    }
                }
                .pickerStyle(SegmentedPickerStyle())
                if numbers[selectorIndex]=="Alphabetically"
                {
                    ForEach(appointments_title)
                    {
                        order in
                        HStack
                        {
                            Text("\(order.title)").font(.headline)
                            Spacer()
                            Text("\(order.date, formatter: ContentView.self.taskDateFormat)").font(.headline)
                        }.padding(.bottom).contentShape(Rectangle())
                            .onTapGesture   { order.isExpanded.toggle() }//.animation(.linear(duration: 0.3))
                        if order.isExpanded { Text("\(order.descript)").frame(maxWidth: .infinity, alignment: .topLeading).padding(.bottom) }
                        else    { EmptyView() }
                    }
                }

}

1

There are 1 best solutions below

5
On BEST ANSWER

This is default behavior and will have something to do with the formatting of the list. I would compare both sets of code and check:

  1. They may have different parent view structures (ie. placed differently within NavigationViews),

  2. You may be using Sections or Groups in your code,

  3. You can also add one of the ListStyle modifiers on the List to override their default style:

        .listStyle(PlainListStyle())
        .listStyle(InsetListStyle())
        .listStyle(GroupedListStyle())
        .listStyle(SidebarListStyle())
        .listStyle(InsetGroupedListStyle())
        .listStyle(DefaultListStyle())