我可以子类化 UIMenuController 以便它可以使用图标而不仅仅是文本吗?
人们会如何去做这件事呢?我正在寻找一个密集的、纯图形的长按菜单。
How would one go about doing this? I'm looking for a dense, purely graphical menu on tap-hold.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 3.2 中,您可以使用
menuItems
属性添加菜单项。但我认为子类化没有用,因为它是一个单例,不会返回每个菜单项的视图。当调用setMenuVisible:animated:
时,您可以访问menuFrame
,因此您可以添加自己的视图,该视图看起来像带有图标的菜单项。但是为了向系统菜单项添加图标......我认为你应该坚持苹果给你的东西;)In 3.2 you can add menu items using the
menuItems
property. But I think subclassing won't be useful, since it's a singleton that does not returns the views of each menu item. You could accessmenuFrame
whensetMenuVisible:animated:
is called, so you can add you're own view that looks like a menu items with icons. But for adding icons to the system menu items... I think you should stick to what's Apple is giving you ;)我的低声誉不允许我发布链接,因此我在这里再次回答:
检查表情符号和表情符号符号,也许它会适合你的目的。
转到您的 Xcode 菜单 ->编辑->表情符号和符号。
例如:
祝你好运!
My low reputation don't let me post links, therefore I am answering again here:
Check Emoji & Symbols, perhaps it will fit to your purpose.
Go to your Xcode Menu -> Edit -> Emoji & Symbols.
Ex.:
Good luck!
我编写了一个类别来支持 UIMenuItem 的图像。它基于方法调配,但在大多数情况下应该是安全的。
https://github.com/cxa/CXAImageMenuItem
注意:重复回答 https://stackoverflow.com/a/14140904/395213
编辑:上面的链接是404'ed,此链接有效
https://github.com/cxa/UIMenuItem-CXAImageSupport
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/CXAImageMenuItem
Note: duplicate answer to https://stackoverflow.com/a/14140904/395213
EDIT: the above link is 404'ed, this link works
https://github.com/cxa/UIMenuItem-CXAImageSupport