Can UIMenuItem show UIImage?

后端 未结 3 1883
春和景丽
春和景丽 2021-01-23 11:51

I saw that it\'s possible — iBooks application does it.

Is it any way to do it?

相关标签:
3条回答
  • 2021-01-23 12:20

    Check Emoji & Symbols, perhaps it will fit to your purpose.

    Go to your Xcode Menu -> Edit -> Emoji & Symbols.

    Ex.:

    let menuItemYes = UIMenuItem(title: "✅", action: "doSomething")
    

    Good luck!

    0 讨论(0)
  • 2021-01-23 12:21

    I wrote a category to support image for UIMenuItem. It's based on method swizzling, but should be safe in most cases.

    https://github.com/cxa/UIMenuItem-CXAImageSupport

    0 讨论(0)
  • 2021-01-23 12:28

    There is nothing in the current official API do that. UIMenuItem can only be initialised with -initWithTitle:action:

    I suspect that Apple either using a private API or have implemented a custom control. Probably the former.

    Asked previously here

    0 讨论(0)
提交回复
热议问题