Previous to watchOS 9 you could present a sheet without any out of the box way to cancel or dismiss. However starting in watchOS 9 presenting a sheet also presents a cancel button in the top left of the navigation bar. How can I remove this and handle dismissing myself?
import SwiftUI
struct ContentView: View {
@State var isShowingSheet = false
var body: some View {
VStack {
Button("show sheet") {
isShowingSheet.toggle()
}
}
.sheet(isPresented: $isShowingSheet) {
Text("Sheet 1")
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Same issue here, tried an empty view in a ToolBarItem but did not work. I ended up using this:
What you do is that you set an empty title, and you tell it to go at the same place as of the cancel button.
PS:it looks like @Kurt Lane was a bit faster in the comment. Credits to him.