Skip to content

Instantly share code, notes, and snippets.

@eivindml
Created October 26, 2018 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eivindml/303db29334586f0dd0e5c046cc0e5f76 to your computer and use it in GitHub Desktop.
Save eivindml/303db29334586f0dd0e5c046cc0e5f76 to your computer and use it in GitHub Desktop.
private extension MenuButtonsViewController {
// TODO: Find a way to find correct button based on MenuItem
func buttonFor(for menuItem: MenuItem) -> EmojiButton? {
guard let subViews = stackView.subviews as? [EmojiButton] else {
return nil
}
let button = buttonFactory.makeEmojiButton(title: menuItem.icon)
for subView in subViews where subView == button {
return subView
}
return nil
}
}
// I have an array (UIStackView) with a varying number of buttons (EmojiButton).
// The buttons are created with content from MenuItem. I'm looking for a good and clean
// solution how to find and remove a particular button from the stackView array, based on a MenuItem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment