The problem is that the title and the item of the navigation bar does not disappear which is an unexpected behaviour.
struct DestinationView: View {
@State private var showingActionSheet = false
var body: some View {
Text("DestinationView")
.padding(.top, 100)
.navigationBarTitle(Text("Destination"), displayMode: .inline)
.navigationBarItems(trailing: Button(action: {
print("tapped")
}, label: {
Text("second")
}))
.actionSheet(isPresented: self.$showingActionSheet) { () -> ActionSheet in
ActionSheet(title: Text("Settings"), message: nil, buttons: [
.default(Text("Delete"), action: {
}),
.cancel()
])
}
}
}
The problem is that the .navigationBarTitle(), .navigationBarItems() modifiers and the .actionSheet() modifier are under each other in code. (But it can be the .alert() or the .overlay() modifiers as well instead of .actionSheet())
The solution in this case:
struct DestinationView: View {
@State private var showingActionSheet = false
var body: some View {
List {
Text("DestinationView")
.padding(.top, 100)
.navigationBarTitle(Text("Destination"), displayMode: .inline)
.navigationBarItems(trailing: Button(action: {
print("tapped")
}, label: {
Text("second")
}))
}
.actionSheet(isPresented: self.$showingActionSheet) { () -> ActionSheet in
ActionSheet(title: Text("Settings"), message: nil, buttons: [
.default(Text("Delete"), action: {
}),
.cancel()
])
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With