I have view that I’d like to show as a fullScreenCover, I noticed one little issue after presenting it that it does not resize the font when the dynamic type changes. Is there a nice way of fixing this?
Here’s my code
import SwiftUI
struct FullScreenModal: View {
@State var showModal: Bool = false
var body: some View {
VStack {
Text("Parent view")
Button("Open Modal") {
showModal = true
}
}
.fullScreenCover(isPresented: $showModal, content: {
Text("This is a full screen cover.")
})
}
}
#Preview {
FullScreenModal()
}
2
Answers
I got inspired by @Martin Poulsen answer, so I want to keep the size categories the same on Parent and Child views, so for that you'd need to get an instance of sizeCategory Environment object and pass that on to the child the same way that Martin has done. Here's the working example:
Here is an example with a DetailView, and also with only a Text in your sheet. Use .environment(.sizeCategory, .accessibilityExtraExtraExtraLarge)