|
1 |
| -# DLWidgetMenu |
2 |
| - |
3 |
| -**DLWidgetMenu** is a versatile solution for displaying widget menus and can easily be extended with custom layouts and/or animations. |
4 |
| - |
5 |
| -## Preview |
6 |
| - |
7 |
| - |
8 |
| -## Features |
9 |
| - |
10 |
| -**DLWidgetMenu** comes with three built-in layouts: |
11 |
| - |
12 |
| -* `DLWMLinearLayout` |
13 |
| -* `DLWMRadialLayout` |
14 |
| -* `DLWMSpiralLayout`**DLWidgetMenu** uses iOS7's **spring animations** (`DLWMSpringMenuAnimator`) by default, but can easily be provided with your own **custom animations** as well (by subclassing `DLWMMenuAnimator`). |
15 |
| -**DLWidgetMenu** observes its menu items for these **gesture recognizer events**: |
16 |
| - |
17 |
| -* single tap |
18 |
| -* double tap |
19 |
| -* long press |
20 |
| -* pan |
21 |
| -* pinch |
22 |
| - |
23 |
| -and **forwards them** directly to its **delegate**. |
24 |
| - |
25 |
| -None of these events make **DLWidgetMenu** do anything by default. |
26 |
| -The menu (by default) **doesn't even open**, when you **tap it**! |
27 |
| - |
28 |
| -And **it shouldn't**. |
29 |
| - |
30 |
| -**DLWidgetMenu** was specifically **designed** to keep you in full control over **its behaviour**. All it does is animating and layouting its menu items. Keeping **you in total charge** of **what to do** and **when**. |
31 |
| - |
32 |
| -Assuming you do want **DLWidgetMenu** to open when single-tapped, all you need to do is implement this in your `DLWMMenuDelegate`: |
33 |
| - |
34 |
| -```objc |
35 |
| -- (void)receivedSingleTap:(UITapGestureRecognizer *)recognizer onItem:(DLWMMenuItem *)item inMenu:(DLWMMenu *)menu { |
36 |
| - if ([menu isClosedOrClosing]) { |
37 |
| - [menu open]; |
38 |
| - } else if ([menu isOpenedOrOpening]) { |
39 |
| - if (item == menu.mainItem) { |
40 |
| - [menu close]; |
41 |
| - } else { |
42 |
| - [menu closeWithSpecialAnimator:[[DLWMSelectionMenuAnimator alloc] init] forItem:item]; |
43 |
| - } |
44 |
| - } |
45 |
| -} |
46 |
| -``` |
47 |
| - |
48 |
| -As you can see the delegate makes **DLWidgetMenu** use a custom animator for the tapped menu item by calling: |
49 |
| - |
50 |
| -```objc |
51 |
| -[menu closeWithSpecialAnimator:[[DLWMSelectionMenuAnimator alloc] init] forItem:item]; |
52 |
| -``` |
53 |
| -
|
54 |
| -(The built-in `DLWMSelectionMenuAnimator` applies a **scale-up** in combination with a **fade-out**.) |
55 |
| -
|
56 |
| -Don't want that? Fine, just call `[menu close];` then. |
57 |
| -
|
58 |
| -Okay, tapping is pretty standard stuff, right? Nothing too fancy. |
59 |
| -So how about **moving** a **menu around** using a **pan gesture**? Piece of cake: |
60 |
| -
|
61 |
| -```objc |
62 |
| -- (void)receivedPan:(UIPanGestureRecognizer *)recognizer onItem:(DLWMMenuItem *)item inMenu:(DLWMMenu *)menu { |
63 |
| - // NSLog(@"%s", __FUNCTION__); |
64 |
| - if (item == menu.mainItem) { |
65 |
| - [menu moveTo:[recognizer locationInView:menu.superview] animated:NO]; |
66 |
| - } |
67 |
| -} |
68 |
| -``` |
69 |
| -**** |
70 |
| -It's worth mentioning here that one should usually prefer `[menu moveTo:… animated:…];` over `menu.center = …;` (while the menu is open, that is). |
71 |
| - |
72 |
| -The reason for this is that **DLWidgetMenu** shrinks to just wrap its main item when closed and stretches to fit its superview when opened (in order to catch tap events outside its menu items). Just enable the debugging-mode (`menu.debuggingEnabled = YES;`) and you should get an idea of what this means. |
73 |
| - |
74 |
| -## Installation |
75 |
| - |
76 |
| -Just copy the files in `"DLWidgetMenu/Classes/..."` into your project. |
77 |
| - |
78 |
| -Alternatively you can install DLWidgetMenu into your project with [CocoaPods](http://cocoapods.org/). |
79 |
| -Just add it to your Podfile: `pod 'DLWidgetMenu'` |
80 |
| - |
81 |
| -## Demos |
82 |
| - |
83 |
| -**DLWidgetMenu** contains a demo app giving you a quick overview of all three included layouts. |
84 |
| - |
85 |
| -## ARC |
86 |
| - |
87 |
| -**DLWidgetMenu** uses **automatic reference counting (ARC)**. |
88 |
| - |
89 |
| -## Dependencies |
90 |
| - |
91 |
| -None. |
92 |
| - |
93 |
| -## Creator |
94 |
| - |
95 |
| -Vincent Esche ([@regexident](http://twitter.com/regexident)) |
96 |
| - |
97 |
| -## License |
98 |
| - |
99 |
| -**DLWidgetMenu** is available under a **modified BSD-3 clause license** with the **additional requirement of attribution**. See the `LICENSE` file for more info. |
| 1 | +# DLWidgetMenu [](http://unmaintained.tech/) |
| 2 | + |
| 3 | +**DLWidgetMenu** is a versatile solution for displaying widget menus and can easily be extended with custom layouts and/or animations. |
| 4 | + |
| 5 | +## Preview |
| 6 | + |
| 7 | + |
| 8 | +## Features |
| 9 | + |
| 10 | +**DLWidgetMenu** comes with three built-in layouts: |
| 11 | + |
| 12 | +* `DLWMLinearLayout` |
| 13 | +* `DLWMRadialLayout` |
| 14 | +* `DLWMSpiralLayout` |
| 15 | + |
| 16 | +**DLWidgetMenu** uses iOS7's **spring animations** (`DLWMSpringMenuAnimator`) by default, but can easily be provided with your own **custom animations** as well (by subclassing `DLWMMenuAnimator`). |
| 17 | + |
| 18 | +**DLWidgetMenu** observes its menu items for these **gesture recognizer events**: |
| 19 | + |
| 20 | +* single tap |
| 21 | +* double tap |
| 22 | +* long press |
| 23 | +* pan |
| 24 | +* pinch |
| 25 | + |
| 26 | +and **forwards them** directly to its **delegate**. |
| 27 | + |
| 28 | +None of these events make **DLWidgetMenu** do anything by default. |
| 29 | +The menu (by default) **doesn't even open**, when you **tap it**! |
| 30 | + |
| 31 | +And **it shouldn't**. |
| 32 | + |
| 33 | +**DLWidgetMenu** was specifically **designed** to keep you in full control over **its behaviour**. All it does is animating and layouting its menu items. Keeping **you in total charge** of **what to do** and **when**. |
| 34 | + |
| 35 | +Assuming you do want **DLWidgetMenu** to open when single-tapped, all you need to do is implement this in your `DLWMMenuDelegate`: |
| 36 | + |
| 37 | +```objc |
| 38 | +- (void)receivedSingleTap:(UITapGestureRecognizer *)recognizer onItem:(DLWMMenuItem *)item inMenu:(DLWMMenu *)menu { |
| 39 | + if ([menu isClosedOrClosing]) { |
| 40 | + [menu open]; |
| 41 | + } else if ([menu isOpenedOrOpening]) { |
| 42 | + if (item == menu.mainItem) { |
| 43 | + [menu close]; |
| 44 | + } else { |
| 45 | + [menu closeWithSpecialAnimator:[[DLWMSelectionMenuAnimator alloc] init] forItem:item]; |
| 46 | + } |
| 47 | + } |
| 48 | +} |
| 49 | +``` |
| 50 | + |
| 51 | +As you can see the delegate makes **DLWidgetMenu** use a custom animator for the tapped menu item by calling: |
| 52 | + |
| 53 | +```objc |
| 54 | +[menu closeWithSpecialAnimator:[[DLWMSelectionMenuAnimator alloc] init] forItem:item]; |
| 55 | +``` |
| 56 | +
|
| 57 | +(The built-in `DLWMSelectionMenuAnimator` applies a **scale-up** in combination with a **fade-out**.) |
| 58 | +
|
| 59 | +Don't want that? Fine, just call `[menu close];` then. |
| 60 | +
|
| 61 | +Okay, tapping is pretty standard stuff, right? Nothing too fancy. |
| 62 | +So how about **moving** a **menu around** using a **pan gesture**? Piece of cake: |
| 63 | +
|
| 64 | +```objc |
| 65 | +- (void)receivedPan:(UIPanGestureRecognizer *)recognizer onItem:(DLWMMenuItem *)item inMenu:(DLWMMenu *)menu { |
| 66 | + // NSLog(@"%s", __FUNCTION__); |
| 67 | + if (item == menu.mainItem) { |
| 68 | + [menu moveTo:[recognizer locationInView:menu.superview] animated:NO]; |
| 69 | + } |
| 70 | +} |
| 71 | +``` |
| 72 | +**** |
| 73 | +It's worth mentioning here that one should usually prefer `[menu moveTo:… animated:…];` over `menu.center = …;` (while the menu is open, that is). |
| 74 | + |
| 75 | +The reason for this is that **DLWidgetMenu** shrinks to just wrap its main item when closed and stretches to fit its superview when opened (in order to catch tap events outside its menu items). Just enable the debugging-mode (`menu.debuggingEnabled = YES;`) and you should get an idea of what this means. |
| 76 | + |
| 77 | +## Installation |
| 78 | + |
| 79 | +Just copy the files in `"DLWidgetMenu/Classes/..."` into your project. |
| 80 | + |
| 81 | +Alternatively you can install DLWidgetMenu into your project with [CocoaPods](http://cocoapods.org/). |
| 82 | +Just add it to your Podfile: `pod 'DLWidgetMenu'` |
| 83 | + |
| 84 | +## Demos |
| 85 | + |
| 86 | +**DLWidgetMenu** contains a demo app giving you a quick overview of all three included layouts. |
| 87 | + |
| 88 | +## ARC |
| 89 | + |
| 90 | +**DLWidgetMenu** uses **automatic reference counting (ARC)**. |
| 91 | + |
| 92 | +## Dependencies |
| 93 | + |
| 94 | +None. |
| 95 | + |
| 96 | +## Creator |
| 97 | + |
| 98 | +Vincent Esche ([@regexident](http://twitter.com/regexident)) |
| 99 | + |
| 100 | +## License |
| 101 | + |
| 102 | +**DLWidgetMenu** is available under a **modified BSD-3 clause license** with the **additional requirement of attribution**. See the `LICENSE` file for more info. |
0 commit comments