skip to Main Content

Example below,

enter image description here

Is this popup style now available standard in iOS? (Perhaps as one of the huge number of variations of the new ‘popup style buttons’?)

I know that some people on here are clever enough to inspect apps and see what the classes are; I can’t.

Is this a standard now-available interface element, or is it just custom programming?

It’s a "full time job" keeping track of what’s available in UIKit and I do not know the answer in this case.

2

Answers


  1. Chosen as BEST ANSWER

    My confusion was I was too dumb to realize that you can (easily) use the standard popup with any button whatsoever. (Not just the two that are available in the standard selection in Xcode.)

    The secret is just

     showsMenuAsPrimaryAction = true
    

    enter image description here

    Create a button (or even a bar button) with any Type, Style, styling, colors etc whatsoever, say on IB.

    Simply do this,

    @IBOutlet weak var test: UIButton!
    func setup() {
        test.showsMenuAsPrimaryAction = true
        
    

    .. and in the usual way build the menu,

        let hh = ["Cats", "Dogs", "Horsies", "Goldfish"]
        test.menu = UIMenu(children: hh.map({ h in
            return UIAction(title: h, image: UIImage(systemName: "eraser")) { _ in
                print("tapped (h)")
            }
        }))
        test.forceSelectedIndex(0)
    }
    

    and that's it.

    It may help anyone googling here.


  2. It’s Pop-Up Button made with UIMenu (main starting class) and is available on iOS 13+ (since your question is about iOS).

    An intro on WWDC 21: Meet the UIKit Button System (at ~12 minutes)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search