Skip to content

Instantly share code, notes, and snippets.

@achernoprudov
Created July 27, 2021 10:07
Show Gist options
  • Save achernoprudov/47cfaa4766869116c3ad39951dd8b92e to your computer and use it in GitHub Desktop.
Save achernoprudov/47cfaa4766869116c3ad39951dd8b92e to your computer and use it in GitHub Desktop.
Building UIMenu in an old way
var actions: [UIAction] = []
actions.append(UIAction(title: "Open", image: UIImage(systemName: "xmark.octagon")) { _ in
...
})
// Sub menu
var subMenuActions: [UIAction] = []
if item.isHidden {
subMenuActions.append(UIAction(title: "Show", image: UIImage(systemName: "eye")) { _ in
...
})
} else {
subMenuActions.append(UIAction(title: "Hide", image: UIImage(systemName: "eye.slash")) { _ in
...
})
}
subMenuActions.append(UIAction(title: "Delete", image: UIImage(systemName: "bin")) { _ in
...
})
actions.append(UIMenu(title: "Edit", children: subMenuActions))
return UIMenu(children: actions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment