Skip to content

Commit 32f34ae

Browse files
Adding Files
1 parent c62f2b0 commit 32f34ae

File tree

67 files changed

+3442
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+3442
-0
lines changed

Assets/facebookHighlight.png

71.9 KB
Loading

Assets/fullCircle.png

72 KB
Loading

Assets/twitterHighlight.png

70.5 KB
Loading

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# iOSContextualMenu CHANGELOG
2+
3+
## 0.1.0
4+
5+
Initial release.

Classes/BAMContextualMenu.h

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
//
2+
// HMContextualMenuItem.h
3+
//
4+
// Created by Hector Matos on 4/2/14.
5+
//
6+
// Copyright (c) 2014 Hector Matos <[email protected]>
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files (the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions:
14+
//
15+
// The above copyright notice and this permission notice shall be included in
16+
// all copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
// THE SOFTWARE.
25+
26+
#import <UIKit/UIKit.h>
27+
28+
typedef enum HMContextualMenuActivateOption : NSUInteger {
29+
kBAMContextualMenuActivateOptionLongPress = 0,
30+
kBAMContextualMenuActivateOptionTouchUp = 1,
31+
} BAMContextualMenuActivateOption;
32+
33+
@protocol BAMContextualMenuDelegate, BAMContextualMenuDataSource;
34+
35+
@interface BAMContextualMenu : UIView
36+
37+
@property (nonatomic) BOOL shouldActivateMenu; //Flag to turn off the ability to activate the popup menu. Defaults to YES but will be NO if menuItems array is nil or empty.
38+
@property (nonatomic) BOOL shouldHighlightOutwards; //Defaults to YES. This flag determines whether or not the menu item will animate outwards on highlight. Or just stay in place.
39+
40+
@property (nonatomic) CGFloat menuItemDistancePadding; //Distance of each menuItem from the edge of the startingCircle (the thing that indicates your touch)
41+
42+
@property (nonatomic) BAMContextualMenuActivateOption activateOption; //User can set this to switch between ways to activate the menu later on.
43+
44+
//This will tear down all subviews will calling all implemented data source and delegate methods.
45+
- (void)reloadDataAndRelayoutSubviews;
46+
47+
/**
48+
Adds Contextual Menu
49+
@param containingView View that the contextual menu bases most of it's stuff on. Unless the long press is inside of the containingView's bounds, the menu will not activate.
50+
@param activateOption An option you can pass to control whether the menu is presented on a long press or by tapping on it. Long pressing will cause the menu to dismiss when the user lifts their finger, while the tap gesture keeps the menu up until the user either taps on a menu item or
51+
**/
52+
+ (BAMContextualMenu *)addContextualMenuToView:(UIView *)containingView delegate:(id <BAMContextualMenuDelegate>)delegate dataSource:(id <BAMContextualMenuDataSource>)dataSource activateOption:(BAMContextualMenuActivateOption)activateOption;
53+
54+
//Removes the contextual menu from containing view as a subview. This is in case you have need for that sort of thing. You would use this in the prepareForReuse method of your UITableViewCell or UICollectionViewReusableView subclass. Failure to do so could result in a objc_msgSend crash due to the longPressGestureRecognizer being added to the view
55+
+ (void)removeContextualMenuFromView:(UIView *)containingView;
56+
57+
@end
58+
59+
@protocol BAMContextualMenuDelegate <NSObject>
60+
61+
//fires on touch up. From there you can perform whatever action needed for that menu item.
62+
- (UIView *)contextualMenu:(BAMContextualMenu *)contextualMenu viewForMenuItemAtIndex:(NSUInteger)index;
63+
64+
@optional
65+
- (void)contextualMenu:(BAMContextualMenu *)contextualMenu didSelectItemAtIndex:(NSUInteger)index;
66+
- (void)contextualMenu:(BAMContextualMenu *)contextualMenu didHighlightItemAtIndex:(NSUInteger)index;
67+
- (UIView *)contextualMenu:(BAMContextualMenu *)contextualMenu viewForHighlightedMenuItemAtIndex:(NSUInteger)index;
68+
- (NSString *)contextualMenu:(BAMContextualMenu *)contextualMenu titleForMenuItemAtIndex:(NSUInteger)index;
69+
- (UIFont *)contextualMenu:(BAMContextualMenu *)contextualMenu fontForMenuItemTitleViewAtIndex:(NSUInteger)index;
70+
- (UIView *)contextualMenu:(BAMContextualMenu *)contextualMenu titleViewForMenuItemAtIndex:(NSUInteger)index;
71+
72+
@end
73+
74+
@protocol BAMContextualMenuDataSource <NSObject>
75+
76+
- (NSUInteger)numberOfContextualMenuItems;
77+
78+
@optional
79+
80+
@end

0 commit comments

Comments
 (0)