Предпочтительный темный режим: ColorScheme не обновляет кнопкиIOS

Программируем под IOS
Anonymous
Предпочтительный темный режим: ColorScheme не обновляет кнопки

Сообщение Anonymous »


Does anyone know why this might be?

I am trying to give my users the option to set dark mode as a preference within the app.

I am using AppStorage to save the users choice and using preferredColorScheme on the Root view to update the entire app.

For the most part this is working and used to work fine. But since iOS 16/17 Buttons or NavigationLinks don't update their color. For example. I have a white system background that changes to black as expected but the text of all Buttons doesn't change and looks hidden on the black background. Yet normal text updates fine.
struct ContentView: View { @AppStorage("darkMode") var isDarkMode: Bool = false var body: some View { VStack { Text("Hello, world!") Button { // } label: { Text("click me") } Toggle("", isOn: $isDarkMode) } .padding() .preferredColorScheme(isDarkMode ? .dark : nil) } }

Источник: https://stackoverflow.com/questions/780 ... ng-buttons

Вернуться в «IOS»