Description:
I’m currently working on a SwiftUI application inspired by Apple Maps, where I have a primary sheet on the home view with a background set to .ultraThinMaterial.
The sheet works well most of the time, but I’m encountering an issue where, especially when opening the CarDetailsSheet
, the .ultraThinMaterial
background is not consistently applied, and a white background appears instead (randomly).
// Code for presenting the primary sheet
.sheet(isPresented: .constant(true)) {
BottomSheet()
.presentationDetents([.medium, .large, .height(geometry.safeAreaInsets.bottom + 32)])
.presentationBackgroundInteraction(.enabled)
.presentationBackground(.ultraThinMaterial)
.interactiveDismissDisabled()
}
// Code for the BottomSheet
struct BottomSheet: View {
// ... (omitting some code for brevity)
// Sheet for presenting details
.sheet(item: $selectedCar) { car in
VStack {
Spacer()
CarDetailsSheet(car.id)
.padding()
.presentationBackground(.ultraThinMaterial)
}
}
// ... (omitting some code for brevity)
}
I’ve tried various approaches, such as adjusting the order of modifiers and removing unnecessary background modifiers, but the issue persists. Specifically, when opening the CarDetailsSheet, it sometimes comes with the proper ultraThinMaterial background, and sometimes it comes with a white background.
Any insights or suggestions on resolving this inconsistency would be greatly appreciated.
Additional Information:
Xcode version: 15.1 (15C65)
iOS version: 17.2