3 `MenuItemKit` provides image and block(closure) support for `UIMenuItem`.
5 `MenuItemKit` is a Swift project but Objective-C is supported without any doubt.
10 1. Add the `MenuItemKit` repository as a submodule of your application’s repository.
11 2. Drag and drop `MenuItemKit.xcodeproj` into your application’s Xcode project or workspace.
12 3. On the “General” tab of your application target’s settings, add `MenuItemKit.framework` to the “Embedded Binaries” section.
14 If you would prefer to use Carthage or CocoaPods, please pull request.
16 `MenuItemKit` is very easy to adopt, it provides only 2 APIs:
19 typealias MenuItemAction = (UIMenuItem) -> ()
21 extension UIMenuItem {
22 convenience init(title: String, image: UIImage?, action: MenuItemAction)
23 convenience init(title: String, action: MenuItemAction)
27 For Objective-C, `MenuItemKit` provides prefixed API names for safe reasons:
30 @interface UIMenuItem (SWIFT_EXTENSION(MenuItemKit))
31 - (nonnull instancetype)mik_initWithTitle:(NSString * _Nonnull)title image:(UIImage * _Nullable)image action:(MenuItemAction _Nonnull)action;
32 - (nonnull instancetype)mik_initWithTitle:(NSString * _Nonnull)title action:(MenuItemAction _Nonnull)action;
36 Just init `UIMenuItem`s with above APIs, and set them to `menuItems` of `UIMenuItemController`. `MenuItemKit` will take care of the rest parts, you don't need to add any code related to responder chain in your view or view controller.
38 Check dome projects (both Swift and Objective-C are provided) for more details.
42 * Twitter: [@_cxa](https://twitter.com/_cxa)
43 * Apps available in App Store: <http://lazyapps.com>
44 * PayPal: xianan.chen+paypal 📧 gmail.com, buy me a cup of coffee if you find it's useful for you, thanks.
48 `MenuItemKit` is released under the MIT license. In short, it's royalty-free but you must keep the copyright notice in your code or software distribution.