Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created July 12, 2020 13:19
Show Gist options
  • Save sturdysturge/cfab581b1eaf8eddb7ab80d76b67c25b to your computer and use it in GitHub Desktop.
Save sturdysturge/cfab581b1eaf8eddb7ab80d76b67c25b to your computer and use it in GitHub Desktop.
RevDoc Menu
import SwiftUI
@available(OSX 10.16, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
struct MenuView : View {
@State var selectedOption = "Select an option"
var body : some View {
HStack {
Menu(selectedOption) {
Button(action: {self.selectedOption = "Option 1"}) {
Text("Option 1")
}
Button(action: {self.selectedOption = "Option 2"}) {
Text("Option 2")
}
Button(action: {self.selectedOption = "Option 3"}) {
Text("Option 3")
}
}
.menuStyle(BorderedButtonMenuStyle())
Menu(selectedOption) {
Button(action: {self.selectedOption = "Option 1"}) {
Text("Option 1")
}
Button(action: {self.selectedOption = "Option 2"}) {
Text("Option 2")
}
Button(action: {self.selectedOption = "Option 3"}) {
Text("Option 3")
}
}
.menuStyle(BorderlessButtonMenuStyle())
Menu(selectedOption) {
Button(action: {self.selectedOption = "Option 1"}) {
Text("Option 1")
}
Button(action: {self.selectedOption = "Option 2"}) {
Text("Option 2")
}
Button(action: {self.selectedOption = "Option 3"}) {
Text("Option 3")
}
}
.menuStyle(DefaultMenuStyle())
}
.padding()
.frame(height: 50)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment