• Stars
    star
    300
  • Rank 138,870 (Top 3 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 2 years ago

Reviews

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

Repository Details

RadialMenu is a custom control for providing a touch context menu (like iMessage recording in iOS 8) built with Swift & POP

RadialMenu

Experimental Software: Fun to play with, but probably shouldn't put it in production (yet).

RadialMenu is a custom control that allows you to provide a context menu to a user on a touch screen (generally after a long press). This is similar to the record functionality Apple introduced for iMessage in iOS 8.

Here's an example of the iMessage menu recreated, taken from the demo app:

iMessage RadialMenu Custom Control Example

You can create your own custom menus as well

Custom RadialMenu Control Example

Plus it's built with Facebook POP, so it's very flexible!

Read the blog entry at http://bradjasper.com/blog/radialmenu-imessage-ios8/ for more information.

Install

Copy the source files from the RadialMenu/ directory into your project.

How to use?

There are two examples provided which show how to use the control in detail (download and run the Xcode project). At a highlevel:

// Create a radial submenu (it's just a UIView subclass)
let subMenuRed = RadialSubMenu(frame: frameOfSubMenu)
subMenuRed.userInteractionEnabled = true
subMenuRed.layer.cornerRadius = subMenuRadius
subMenuRed.layer.backgroundColor = UIColor.redColor()
subMenuRed.layer.borderColor = UIColor.blackColor()
subMenuRed.layer.borderWidth = 1
subMenuRed.tag = tag


// Create multiple submenus and assign to array
let subMenus = [subMenuRed, subMenuBlue, ...]


// Initialize the radial menu
let radialMenu = RadialMenu(menus: subMenus, radius: menuRadius)
radialMenu.center = view.center
radialMenu.openDelayStep = 0.05
radialMenu.closeDelayStep = 0.00
radialMenu.minAngle = 180
radialMenu.maxAngle = 360
radialMenu.activatedDelay = 1.0
radialMenu.backgroundView.alpha = 0.0

// Setup event handlers for specific actions
radialMenu.onOpen = {
    // menu has opened
}

radialMenu.onHighlight = { subMenu in
    // perform highlight change
}

radialMenu.onActivate = { subMenu in
    // did select subMenu
}


// Setup menu to show when pressing a button
let longPress = UILongPressGestureRecognizer(target: self, action: "pressedButton:")
button.addGestureRecognizer(longPress)

// Gesture handler can react to menu in different ways depending what you want
// (for example, keeping the menu open if nothing is selected)
func pressedButton(gesture:UIGestureRecognizer) {
    switch(gesture.state) {
        case .Began:
            radialMenu.openAtPosition(button.center)
        case .Ended:
            radialMenu.close()
        case .Changed:
            radialMenu.moveAtPosition(gesture.locationInView(self.view))
        default:
            break
    }
}

Todo

  • Documentation
  • Convert to NSControl sublcass
  • Figure out CocoaPods/framework distribution for Swift
  • Fix other FIXME's & TODO's in source code

LICENSE

MIT

Read More

Contact

Web: http://bradjasper.com
Twitter: @bradjasper
Email: [email protected]

More Repositories

1

ImportJSON

Import JSON into Google Sheets, this library adds various ImportJSON functions to your spreadsheet
HTML
2,099
star
2

subtle-patterns-bookmarklet

SubtlePatterns Bookmarklet
CoffeeScript
300
star
3

focus-extension

Official browser extension for Focus (for Firefox)
JavaScript
41
star
4

focus-CLI

Give yourself focus by blocking distracting websites
Shell
38
star
5

Mixpanel-Statistics

Perform statistics on Mixpanel API data
Python
27
star
6

Markov-Chains

Experiments with Markov Chains
Python
21
star
7

django-wordpress-parser

Wordpress eXtended RSS Parser (in Python for Django)
Python
17
star
8

python-p2p

Experiments with P2P networks in Python
Python
7
star
9

Download-iTunes-Icon

Quickly download icons from iTunes, add rounded corners + @2x and @3x sized assets
Ruby
6
star
10

Yelp-Recommendations

Experiments in providing business suggestions based on Yelp ratings
Python
5
star
11

node-semaphore

A small semaphore in vanilla JS, useful as a lock pool for something like rate limiting
JavaScript
5
star
12

django-pickledfield

Pickled Field
Python
5
star
13

hosting-choice

Hosting Choice
Python
4
star
14

instockdomains

Domain Availability Website
Python
3
star
15

parappa-the-wrapper

Parappa (the wrapper) wraps other commands in a REPL
Shell
3
star
16

Blackhole-HTTP-HTTPS-Proxy-Server

A proxy server that kills any HTTP or HTTPS request and optionally serves a custom message
Python
3
star
17

django-snippets

Simple snippets of arbitrary text that can be attached to other items
Python
2
star
18

wp-ask-a-question

Wordpress plugin that lets users quickly ask you a question
PHP
2
star
19

Blockchain

A simple blockchain for learning core concepts, written in Python
Python
2
star
20

bradjasper.github.com

BradJasper.com Source Code v3
HTML
2
star
21

lispy.coffee

Implementing Peter Norvig's Python Lisp interpreter (http://norvig.com/lispy.html) in CoffeeScript
JavaScript
2
star
22

django-nomore404

Capture and filter 404 errors
Python
2
star
23

Carousel

jQuery Carousel Plugin - Cycle through a list of elements
CoffeeScript
1
star
24

debugmyuser

debugmyuser.com source code
JavaScript
1
star
25

Music-in-Lisp

Experiments with writing music in lisp
Common Lisp
1
star
26

PyProxy

Small Python proxy build on Webpy
Python
1
star
27

envsync-env

Envsync environment
Vim Script
1
star
28

common

Common Libraries I Re-use
Python
1
star
29

SEOSense

SEO Focused Theme for Wordpress
PHP
1
star
30

NSRunningApplicationMemoryLeaks

Example of memory leaks in NSRunningApplication
Objective-C
1
star
31

jQuery-Slideshow

A simple slideshow plugin for jQuery
CoffeeScript
1
star
32

DomainGroovy

Source code for DomainGroovy.com
HTML
1
star
33

Concurrency

Tests in Concurrency
Python
1
star
34

moirae

Automatically exported from code.google.com/p/moirae
Objective-C
1
star
35

proj

Lightweight project manager in Bash
Shell
1
star
36

attrgettersetter

Flexible attribute getter and setter functions (useful for attribute.dot.syntax w/ default value support)
1
star
37

BJRadialMenu

Animated radial menu for iOS using Facebook POP
Objective-C
1
star
38

sprite

Command line script to generate fixed-width sprites
1
star
39

Todo

Simple todo utility that e-mails you todo items
Shell
1
star
40

Attention-Span

Bounce rate for Mint Analytics
PHP
1
star
41

POP-Experiments

Experiments with Facebook's POP animation library
Objective-C
1
star