How to display BottomSheet programmatically?
Closed this issue · 1 comments
tciuro commented
I am showing a BottomSheet like so:
.bottomSheet(bottomSheetPosition: self.$bottomSheetPosition, options: [.tapToDismiss], content: {
...
})
After it has been dismissed, is there a way to display it again? In other words, is there a way to display it when say, a button has been tapped?
Thanks!
pavelraspaev commented
Hi!
You just need to set var bottomSheetPosition
to .middle
for open state and to .hidden
for close state
Example:
Button {
withAnimation {
bottomSheetPosition = .middle
}
} label: {
Image("add")
.resizable()
.scaledToFit()
.frame(width: 24, height: 24)
}
Hope it helps