Skip to content

gridNA/GNAContextMenu

Repository files navigation

Carthage compatible

GNAContextMenu

Long press context menu (like in Pintrest for iOS app)

Requirements

  • iOS 11.0+
  • Xcode 9.3+

Installation

The easiest way is through CocoaPods. Simply add the dependency to your Podfile and then pod install:

pod `GNAContextMenu`

Or Carthage. Add the depdency to your Cartfile and then carthage update:

github "gridNA/GNAContextMenu"

How

import GNAContextMenu
  1. add on view in UIViewController, where you plan to use context menu
UILongPressGestureRecognizer
  1. create GNAMenuView and set delegate
var menuView = GNAMenuView(menuItems: 
              [GNAMenuItem(icon: UIImage(named: "shopingCart_inactive"), 
                           activeIcon: UIImage(named: "shopingCart"), 
                           title: "Shop it"), 
              GNAMenuItem(icon: UIImage(named: "wishlist_inacitve"), 
                          activeIcon: UIImage(named: "wishlist"), 
                          title: "Wish")])
menuView.delegate = self
  1. on long press
 menuView.handleGesture(gesture, inView: yourView)

You can also implement GNAMenuItemDelegate methods:

  menuItemWasPressed(menuItem: GNAMenuItem, info: [String: AnyObject]?)
  menuItemActivated(menuItem: GNAMenuItem, info: [String: AnyObject]?)
  menuItemDeactivated(menuItem: GNAMenuItem, info: [String: AnyObject]?)

Please see example for more info.

Example

Example