How to detect Light\Dark mode change in iOS 13?

SwiftUI With a simple environment variable on the \.colorScheme key: struct ContentView: View { @Environment(\.colorScheme) var colorScheme var body: some View { Text(colorScheme == .dark ? “Its Dark” : “Its. not dark! (Light)”) } } UIKit As it described in WWDC 2019 – Session 214 around 23:30. As I expected, this function is getting called … Read more

Is it possible to make a modal non-dismissible in SwiftUI?

iOS 15 and later: Use .interactiveDismissDisabled(true) on the sheet, that’s all. Prev iOS 15: You can try to do this by using a highPriorityGesture. Of course the blue Rectangle is only for demonstration but you would have to use a view which is covering the whole screen. struct ModalViewNoClose : View { @Environment(\.presentationMode) var presentationMode … Read more

Show a new View from Button press Swift UI

Possible solutions 1.if you want to present on top of current view(ex: presentation style in UIKit) struct ContentView: View { @State var showingDetail = false var body: some View { Button(action: { self.showingDetail.toggle() }) { Text(“Show Detail”) }.sheet(isPresented: $showingDetail) { DetailView() } } } 2.if you want to reset current window scene stack(ex:after login show … Read more