How could I replace UIMenuController with my own view when text is selected?

后端 未结 2 529
-上瘾入骨i
-上瘾入骨i 2021-01-30 05:27

When text is selected, by default a UIMenuController pops up with cut/copy/paste etc.

\"enter

2条回答
  •  遥遥无期
    2021-01-30 06:25

    I think this may help you https://github.com/cxa/UIMenuItem-CXAImageSupport

    UIMenuItem uses UILabel to display its title, that means we can swizzle -drawTextInRect: to support image.

    UIMenuItem+CXAImageSupport is a dirty hack but should be safe in most cases. Contains no any private API.

    Make a category instead of subclassing for UIMenuItem gains more flexibility. Yes, this category can be applied to the awesome PSMenuItem too!

    enter image description here

提交回复
热议问题