English 中文(简体)
名单背景色正显示黑色的黑色。
原标题:List background color is showing black in dark mode
  • 时间:2024-02-23 13:51:06
  •  标签:
  • swiftui

我想改变名单观点的背景颜色。 我以黑暗的方式表明了名单观点,但每次背景都是黑色。 任何更改背景颜色的建议?

GeometryReader { geometry in
            ZStack {
                (colorScheme == .dark ? Color.SAColor.whiteWithAlpha10 : Theme.BackgroundColor.whiteBackgroundL2)
                VStack(alignment: .leading) {

                    SaudiaNavigationView(viewModel: SaudiaNavigationViewModel(isHeaderPinned: false,
                                                                              title: "", shouldShowProfileDetails: false,
                                                                              showTitleAlways: false,
                                                                              showBackButton: false, normalLightColor: (colorScheme == .dark ? Color.SAColor.whiteWithAlpha10 : Theme.BackgroundColor.whiteBackgroundL2), normalDarkColor: (colorScheme == .dark ? Color.SAColor.whiteWithAlpha10 : Theme.BackgroundColor.whiteBackgroundL2),
                                                                              rightButtonType: .ImageButton(image: SAImageAssetConstants.flightDetailsCloseIcon, accessibilityText: "",
                                                                                                            buttonAction: {
                        presentationMode.wrappedValue.dismiss()
                    }),
                                                                              imageButtonAccessibilityLabel: Accessibility.close))
                    .frame(height: 34 + geometry.safeAreaInsets.top)
                    List {
                        Section {
}
                            .listSectionSeparator(.hidden)
                            .listRowSeparator(.hidden)

                    }
                    .listStyle(.plain)
                    .padding(.top, -15)
                    .padding(.leading, -15)
                    .padding(.trailing, -15)
                    .padding(.bottom, -15)

                }.background(colorScheme == .dark ? Color.SAColor.whiteWithAlpha10 : Theme.BackgroundColor.whiteBackgroundL2)
                    .ignoresSafeArea()
            }.ignoresSafeArea()
        }
        .navigationBarBackButtonHidden()
        .navigationBarTitleDisplayMode(.inline)
    }

所有方言和观点清单都是一种独特的颜色。

最佳回答

这是因为<代码>List有自己的标准背景。

电话:Color.clear as the .listRowBackground on the Section within the List . 还可帮助隐藏使用<代码>的违约清单背景。

List {
    Section {
        // List content
    }
    .listSectionSeparator(.hidden)
    .listRowSeparator(.hidden)
    .listRowBackground(Color.clear) // <- ADDED
}
.listStyle(.plain)     
.scrollContentBackground(.hidden) // <- ADDED
问题回答

暂无回答




相关问题
SwiftUI: How do I position a button x points above a sheet?

I am trying to recreate a Maps-style UI with a persistent bottom sheet and controls fixed above. Apple Maps UI with controls above ☝️ Example here, the "Look Around" binoculars button and ...

How to access own window within SwiftUI view?

The goal is to have easy access to hosting window at any level of SwiftUI view hierarchy. The purpose might be different - close the window, resign first responder, replace root view or ...