• Stars
    star
    848
  • Rank 51,589 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 8 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

UIMenuItem with image and closure(block) action

Warning UIMenuController is deprecated from iOS 16. Use UIEditMenuInteraction instead.

MenuItemKit

MenuItemKit provides image and block(closure) support for UIMenuItem.

MenuItemKit is a Swift project but Objective-C is supported without any doubt.

Screenshot

Install

Swift Package

Add this repo URL to your Swift package dependencies.

CocoaPods

pod 'MenuItemKit', '~> 4.0.0'

Xcode subproject

  1. Add the MenuItemKit repository as a submodule of your application’s repository.
  2. Drag and drop MenuItemKit.xcodeproj into your application’s Xcode project or workspace.
  3. On the “General” tab of your application target’s settings, add MenuItemKit.framework to the “Embedded Binaries” section.

If you would prefer to use Carthage, please pull request.

How to use

MenuItemKit is very easy to adopt, it provides only 2 APIs:

typealias MenuItemAction = (UIMenuItem) -> ()

extension UIMenuItem {
    convenience init(title: String, image: UIImage?, action: MenuItemAction)
    convenience init(title: String, action: MenuItemAction)
}

For Objective-C, MenuItemKit provides prefixed API names for safe reasons:

@interface UIMenuItem (SWIFT_EXTENSION(MenuItemKit))
- (nonnull instancetype)mik_initWithTitle:(NSString * _Nonnull)title image:(UIImage * _Nullable)image action:(MenuItemAction _Nonnull)action;
- (nonnull instancetype)mik_initWithTitle:(NSString * _Nonnull)title action:(MenuItemAction _Nonnull)action;
@end

Just init UIMenuItems 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.

Check dome projects (both Swift and Objective-C are provided) for more details.

Advance Usage

For menu items out of your control, you can use static func installTo(responder: UIResponder, shouldShowForAction: @escaping (Selector, Bool) -> Bool = default) to configure items visibility. Check AutoPopupMenuControllerDemo.

About Me

  • Twitter: @_realazy
  • Apps available in App Store: http://lazyapps.com
  • PayPal: xianan.chen+paypal 📧 gmail.com, buy me a cup of coffee if you find it's useful for you, thanks.

License

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.

More Repositories

1

UIMenuItem-CXAImageSupport

[Deprecated! Use MenuItemKit instead] UIMenuItem with Image Support
Objective-C
338
star
2

ppx_bsx

OCaml JSX for ReasonReact
OCaml
70
star
3

CXAHyperlinkLabel

A drop-in and easy-to-use replacement for UILabel for iOS 6, supports handling link click and long press with block.
Objective-C
51
star
4

KissNSUserDefaults

Keep NSUserDefaults simple, stupid. Access NSUserDefaults key using property, without subclassing.
Objective-C
46
star
5

CXAAutoRemovalNotification

[DEPRECATED] Less boilerplate code for NSNotificationCenter.
Objective-C
32
star
6

CXADirectoryContentsWatcher

Watch for a directory whenever a file is added or removed
Objective-C
30
star
7

DOMContentLoadedDelegate

Access `UIWebView` DOM asap
Swift
28
star
8

WebViewContentPositioner

Scroll position maintainer for UIWebView.
Swift
26
star
9

Mvce

An event driven MVC library to glue decoupled Model, View, and Controller for UIKit/AppKit. Minimal, simple, and unobtrusive.
Swift
23
star
10

Piz

The simplest unzipper just works. (Swift)
Swift
22
star
11

Fpub

Library for reading EPUB file format built on top of .NET Standard 2.0 and F#.
F#
19
star
12

Mu

Apply The Elm Architecture pattern on Xamarin stack, with another simple, unobtrusive way
F#
16
star
13

bs-containers-core

OCaml-containers core for BuckleScript.
OCaml
12
star
14

AppExtensionCommunicator

Communicate between app extension and its containing app. Swift framework.
Swift
12
star
15

NonConsumableIAPHelper

An extra lightweight wrapper for non-consumable In-App Purchase.
Objective-C
10
star
16

reason-react-webpack-starter-kit

JavaScript
9
star
17

ppx_bsx_example

JavaScript
7
star
18

XPaver

Make XML navigation by XPath easier
Swift
7
star
19

JsonR

OCaml
7
star
20

cxa.github.com

Personal page
HTML
6
star
21

HalfTea

Inspired by TEA (The Elm Architecture) but for Xamarin stack, in an unobstrusive way.
F#
5
star
22

vscode-elmx

elmx for Visual Studio Code
4
star
23

bs-websockets

OCaml
4
star
24

HaodooPDB

Extract contents from the PDB format of http://haodoo.net
Objective-C
3
star
25

bs-json-keypather

Navigate JSON with keypath for BuckleScript
OCaml
3
star
26

dicsrv

HTTP service for macOS Dictionary.app.
JavaScript
2
star
27

dicmd

Command line for macOS Dictionary.app
C
1
star
28

chatgpt

ChatGPT in your terminal.
Shell
1
star
29

KeyPathJson

Safe and key-path-able JSON navigator for System.Json
F#
1
star
30

.emacs.d

Relocatable Emacs conf
Emacs Lisp
1
star
31

KissNSUbiquitousKeyValueStore

Keep NSUbiquitousKeyValueStore simple, stupid. Access NSUbiquitousKeyValueStore key using property, without subclassing.
Objective-C
1
star