I have a settings view and I want to change the entire view background color. Using Color(red: 1.000, green: 0.867, blue: 0.525).ignoresSafeArea()
in a ZStack worked for my other views but not for this one. I also tried the background modifier, but it didn't work either. Can you help me find out how I can change the background color of the whole view?
var body: some View {
ZStack {
/// change the background color
Color(red: 1.000, green: 0.867, blue: 0.525).ignoresSafeArea()
List {
Text("Settings")
.font(.largeTitle)
.padding(.bottom, 8)
Section(header: Text("Notifications")) {
HStack {
Toggle("Daily Reminder", isOn: $dailyReminderEnabled).onChange(of: dailyReminderEnabled, perform: {_ in configureNotification()})
DatePicker(
"",
selection: $dailyReminderTime,
displayedComponents: .hourAndMinute
)
.disabled(dailyReminderEnabled == false)
/// .onChange(of:perform:) is part of the View protocol, so you can use it on any view.
.onChange(of: dailyReminderTime, perform: { newValue in
/// This copies the number of seconds since the midnight of Jan 1, 1970, as a double value, into the shadow property for the App Storage.
dailyReminderTimeShadow = newValue.timeIntervalSince1970
configureNotification()})
.onAppear {
/// With it, every time the Section is displayed, the value stored in the shadow property is converted to a date and stored into dailyReminderTime.
dailyReminderTime = Date(timeIntervalSince1970: dailyReminderTimeShadow)
}
}
}
}
}
}