Can UIMenuItem show UIImage?

孤者浪人 提交于 2019-12-02 11:40:23

问题


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

Is it any way to do it?


回答1:


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




回答2:


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




回答3:


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!



来源:https://stackoverflow.com/questions/10395413/can-uimenuitem-show-uiimage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!