├── cmocv.gif ├── cmov.gif ├── cmocv5.gif ├── GHContextMenu ├── en.lproj │ └── InfoPlist.strings ├── twitter.png ├── facebook-white.png ├── linkedin-white.png ├── twitter-white.png ├── pinterest-white.png ├── twitter-white@2x.png ├── facebook-white@2x.png ├── google-plus-white.png ├── linkedin-white@2x.png ├── pinterest-white@2x.png ├── google-plus-white@2x.png ├── GHViewController.h ├── GHCollectionViewController.h ├── GHAppDelegate.h ├── main.m ├── GHContextMenu-Prefix.pch ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── GHContextMenuView.h ├── GHContextMenu-Info.plist ├── GHAppDelegate.m ├── GHViewController.m ├── GHCollectionViewController.m ├── Base.lproj │ └── Main.storyboard └── GHContextMenuView.m ├── GHContextMenuTests ├── en.lproj │ └── InfoPlist.strings ├── GHContextMenuTests-Info.plist └── GHContextMenuTests.m ├── GHContextMenuDemo.xcodeproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── project.pbxproj ├── .gitignore ├── License.txt ├── GHContextMenu.podspec └── README.md /cmocv.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GnosisHub/GHContextMenu/HEAD/cmocv.gif -------------------------------------------------------------------------------- /cmov.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GnosisHub/GHContextMenu/HEAD/cmov.gif -------------------------------------------------------------------------------- /cmocv5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GnosisHub/GHContextMenu/HEAD/cmocv5.gif -------------------------------------------------------------------------------- /GHContextMenu/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /GHContextMenuTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /GHContextMenu/twitter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GnosisHub/GHContextMenu/HEAD/GHContextMenu/twitter.png -------------------------------------------------------------------------------- /GHContextMenu/facebook-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GnosisHub/GHContextMenu/HEAD/GHContextMenu/facebook-white.png -------------------------------------------------------------------------------- /GHContextMenu/linkedin-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GnosisHub/GHContextMenu/HEAD/GHContextMenu/linkedin-white.png -------------------------------------------------------------------------------- /GHContextMenu/twitter-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GnosisHub/GHContextMenu/HEAD/GHContextMenu/twitter-white.png -------------------------------------------------------------------------------- /GHContextMenu/pinterest-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GnosisHub/GHContextMenu/HEAD/GHContextMenu/pinterest-white.png -------------------------------------------------------------------------------- /GHContextMenu/twitter-white@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GnosisHub/GHContextMenu/HEAD/GHContextMenu/twitter-white@2x.png -------------------------------------------------------------------------------- /GHContextMenu/facebook-white@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GnosisHub/GHContextMenu/HEAD/GHContextMenu/facebook-white@2x.png -------------------------------------------------------------------------------- /GHContextMenu/google-plus-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GnosisHub/GHContextMenu/HEAD/GHContextMenu/google-plus-white.png -------------------------------------------------------------------------------- /GHContextMenu/linkedin-white@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GnosisHub/GHContextMenu/HEAD/GHContextMenu/linkedin-white@2x.png -------------------------------------------------------------------------------- /GHContextMenu/pinterest-white@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GnosisHub/GHContextMenu/HEAD/GHContextMenu/pinterest-white@2x.png -------------------------------------------------------------------------------- /GHContextMenu/google-plus-white@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GnosisHub/GHContextMenu/HEAD/GHContextMenu/google-plus-white@2x.png -------------------------------------------------------------------------------- /GHContextMenuDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /GHContextMenu/GHViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // GHViewController.h 3 | // GHContextMenu 4 | // 5 | // Created by Tapasya on 27/01/14. 6 | // Copyright (c) 2014 Tapasya. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GHViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /GHContextMenu/GHCollectionViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // GHCollectionViewController.h 3 | // GHContextMenuDemo 4 | // 5 | // Created by Tapasya on 31/01/14. 6 | // Copyright (c) 2014 Tapasya. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GHCollectionViewController : UICollectionViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /GHContextMenu/GHAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // GHAppDelegate.h 3 | // GHContextMenu 4 | // 5 | // Created by Tapasya on 27/01/14. 6 | // Copyright (c) 2014 Tapasya. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GHAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #OS noise 2 | profile 3 | [Tt]humbs.db 4 | *.DS_Store 5 | *~ 6 | *.swp 7 | *.out 8 | *.bak* 9 | *.lock 10 | 11 | #Other CSM 12 | .hg 13 | .svn 14 | CVS 15 | 16 | 17 | #Xcode noise 18 | *.log 19 | *~.nib 20 | *.moved-aside 21 | *.xcodeproj/* 22 | !*.xcodeproj/project.pbxproj 23 | !xcshareddata 24 | 25 | #Project files 26 | [Bb]uild/ 27 | DerivedData/ 28 | 29 | #CocoaPods 30 | Pods -------------------------------------------------------------------------------- /GHContextMenu/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // GHContextMenu 4 | // 5 | // Created by Tapasya on 27/01/14. 6 | // Copyright (c) 2014 Tapasya. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "GHAppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([GHAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /GHContextMenu/GHContextMenu-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /GHContextMenu/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /GHContextMenu/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /GHContextMenuTests/GHContextMenuTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | Tapasya.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /GHContextMenuTests/GHContextMenuTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // GHContextMenuTests.m 3 | // GHContextMenuTests 4 | // 5 | // Created by Tapasya on 27/01/14. 6 | // Copyright (c) 2014 Tapasya. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GHContextMenuTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation GHContextMenuTests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown 24 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2014 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /GHContextMenu.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "GHContextMenu" 4 | s.version = "0.0.1" 5 | s.summary = "Pinterest like context menu control for iOS" 6 | 7 | s.description = <<-DESC 8 | * This is user friendly solution for showing context menu upon long press. 9 | * It is inspired from the Pinterest iOS app 10 | DESC 11 | 12 | s.homepage = "https://github.com/GnosisHub/GHContextMenu" 13 | s.screenshots = "https://raw2.github.com/GnosisHub/GHContextMenu/master/cmov.gif", "https://raw2.github.com/GnosisHub/GHContextMenu/master/cmocv.gif" 14 | 15 | s.license = { :type => 'MIT', :file => 'License.txt' } 16 | 17 | 18 | 19 | s.author = { "Tapasya" => "tapasyakhs@gmail.com" } 20 | 21 | s.platform = :ios 22 | s.source = { :git => "https://github.com/GnosisHub/GHContextMenu.git", :commit => "a6e8f67d4a2206bfb9ad77814d2b90d2593b6f57" } 23 | 24 | s.source_files = 'GHContextMenu/GHContextMenuView.{h,m}' 25 | s.exclude_files = 'Classes/Exclude' 26 | 27 | 28 | s.framework = 'CoreGraphics' 29 | s.requires_arc = true 30 | 31 | end 32 | -------------------------------------------------------------------------------- /GHContextMenu/GHContextMenuView.h: -------------------------------------------------------------------------------- 1 | // 2 | // GHContextOverlayView.h 3 | // GHContextMenu 4 | // 5 | // Created by Tapasya on 27/01/14. 6 | // Copyright (c) 2014 Tapasya. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSInteger, GHContextMenuActionType){ 12 | // Default 13 | GHContextMenuActionTypePan, 14 | // Allows tap action in order to trigger an action 15 | GHContextMenuActionTypeTap 16 | }; 17 | 18 | @protocol GHContextOverlayViewDataSource; 19 | @protocol GHContextOverlayViewDelegate; 20 | 21 | @interface GHContextMenuView : UIView 22 | 23 | @property (nonatomic, assign) id dataSource; 24 | @property (nonatomic, assign) id delegate; 25 | 26 | @property (nonatomic, assign) GHContextMenuActionType menuActionType; 27 | 28 | - (void) longPressDetected:(UIGestureRecognizer*) gestureRecognizer; 29 | 30 | @end 31 | 32 | @protocol GHContextOverlayViewDataSource 33 | 34 | @required 35 | - (NSInteger) numberOfMenuItems; 36 | - (UIImage*) imageForItemAtIndex:(NSInteger) index; 37 | 38 | @optional 39 | -(BOOL) shouldShowMenuAtPoint:(CGPoint) point; 40 | 41 | @end 42 | 43 | @protocol GHContextOverlayViewDelegate 44 | 45 | - (void) didSelectItemAtIndex:(NSInteger) selectedIndex forMenuAtPoint:(CGPoint) point; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /GHContextMenu/GHContextMenu-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | Tapasya.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /GHContextMenu/GHAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // GHAppDelegate.m 3 | // GHContextMenu 4 | // 5 | // Created by Tapasya on 27/01/14. 6 | // Copyright (c) 2014 Tapasya. All rights reserved. 7 | // 8 | 9 | #import "GHAppDelegate.h" 10 | 11 | @implementation GHAppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | // Override point for customization after application launch. 16 | return YES; 17 | } 18 | 19 | - (void)applicationWillResignActive:(UIApplication *)application 20 | { 21 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 22 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 23 | } 24 | 25 | - (void)applicationDidEnterBackground:(UIApplication *)application 26 | { 27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | - (void)applicationWillEnterForeground:(UIApplication *)application 32 | { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | - (void)applicationDidBecomeActive:(UIApplication *)application 37 | { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application 42 | { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #GHContextMenu - Pinterest like context menu control for iOS 2 | 3 | ![alt tag](https://github.com/GnosisHub/GHContextMenu/blob/master/cmocv.gif) 4 | ![alt tag](https://github.com/GnosisHub/GHContextMenu/blob/master/cmocv5.gif) 5 | ![alt tag](https://github.com/GnosisHub/GHContextMenu/blob/master/cmov.gif) 6 | 7 | This is user friendly solution for showing context menu upon long press. It is inspired from the Pinterest iOS app 8 | 9 | ##How To Use 10 | 11 | Sample app contains examples of how to add context menu for UIView and UICollectionView 12 | 13 | * Add `GHContextMenuView` headers and implementations to your project (2 files total). 14 | * Include with `#import "GHContextMenuView.h"` to use it wherever you need. 15 | * Set and implement the `GHContextMenuViewDataSource` to provide data about the pages. 16 | * Set and implement the `GHContextMenuViewDelegate` to receive callback upon selection. 17 | 18 | ### Sample Code 19 | ```objc 20 | // Creating 21 | GHContextMenuView* overlay = [[GHContextMenuView alloc] init]; 22 | overlay.dataSource = self; 23 | overlay.delegate = self; 24 | 25 | UILongPressGestureRecognizer* _longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:overlay action:@selector(longPressDetected:)]; 26 | [self.view addGestureRecognizer:_longPressRecognizer]; 27 | 28 | // Implementing data source methods 29 | - (NSInteger) numberOfMenuItems 30 | { 31 | return 3; 32 | } 33 | 34 | -(UIImage*) imageForItemAtIndex:(NSInteger)index 35 | { 36 | NSString* imageName = nil; 37 | switch (index) { 38 | case 0: 39 | imageName = @"facebook"; 40 | break; 41 | case 1: 42 | imageName = @"twitter"; 43 | break; 44 | case 2: 45 | imageName = @"google-plus"; 46 | break; 47 | 48 | default: 49 | break; 50 | } 51 | return [UIImage imageNamed:imageName]; 52 | } 53 | 54 | - (void) didSelectItemAtIndex:(NSInteger)selectedIndex forMenuAtPoint:(CGPoint)point 55 | { 56 | NSString* msg = nil; 57 | switch (selectedIndex) { 58 | case 0: 59 | msg = @"Facebook Selected"; 60 | break; 61 | case 1: 62 | msg = @"Twitter Selected"; 63 | break; 64 | case 2: 65 | msg = @"Google Plus Selected"; 66 | break; 67 | 68 | default: 69 | break; 70 | } 71 | 72 | UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 73 | [alertView show]; 74 | 75 | } 76 | 77 | ``` 78 | 79 | ###Next Steps: 80 | Supporting configurations is one of the next steps. Any feature request is welcome. Raise an issue with a feature tag and I will look into it 81 | 82 | 83 | ###License : 84 | 85 | The MIT License 86 | 87 | -------------------------------------------------------------------------------- /GHContextMenu/GHViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // GHViewController.m 3 | // GHContextMenu 4 | // 5 | // Created by Tapasya on 27/01/14. 6 | // Copyright (c) 2014 Tapasya. All rights reserved. 7 | // 8 | 9 | #import "GHViewController.h" 10 | #import "GHContextMenuView.h" 11 | 12 | @interface GHViewController () 13 | 14 | @property (weak, nonatomic) IBOutlet UIImageView *imageView; 15 | 16 | @end 17 | 18 | @implementation GHViewController 19 | 20 | - (void)viewDidLoad 21 | { 22 | [super viewDidLoad]; 23 | // Do any additional setup after loading the view, typically from a nib. 24 | 25 | GHContextMenuView* overlay = [[GHContextMenuView alloc] init]; 26 | overlay.dataSource = self; 27 | overlay.delegate = self; 28 | 29 | UILongPressGestureRecognizer* _longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:overlay action:@selector(longPressDetected:)]; 30 | [self.imageView setUserInteractionEnabled:YES]; 31 | [self.view addGestureRecognizer:_longPressRecognizer]; 32 | } 33 | 34 | - (void)didReceiveMemoryWarning 35 | { 36 | [super didReceiveMemoryWarning]; 37 | // Dispose of any resources that can be recreated. 38 | } 39 | 40 | - (NSInteger) numberOfMenuItems 41 | { 42 | return 3; 43 | } 44 | 45 | -(UIImage*) imageForItemAtIndex:(NSInteger)index 46 | { 47 | NSString* imageName = nil; 48 | switch (index) { 49 | case 0: 50 | imageName = @"facebook-white"; 51 | break; 52 | case 1: 53 | imageName = @"twitter-white"; 54 | break; 55 | case 2: 56 | imageName = @"google-plus-white"; 57 | break; 58 | case 3: 59 | imageName = @"linkedin-white"; 60 | break; 61 | case 4: 62 | imageName = @"pinterest-white"; 63 | break; 64 | 65 | default: 66 | break; 67 | } 68 | return [UIImage imageNamed:imageName]; 69 | } 70 | 71 | - (void) didSelectItemAtIndex:(NSInteger)selectedIndex forMenuAtPoint:(CGPoint)point 72 | { 73 | NSString* msg = nil; 74 | switch (selectedIndex) { 75 | case 0: 76 | msg = @"Facebook Selected"; 77 | break; 78 | case 1: 79 | msg = @"Twitter Selected"; 80 | break; 81 | case 2: 82 | msg = @"Google Plus Selected"; 83 | break; 84 | case 3: 85 | msg = @"Linkedin Selected"; 86 | break; 87 | case 4: 88 | msg = @"Pinterest Selected"; 89 | break; 90 | 91 | default: 92 | break; 93 | } 94 | 95 | UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 96 | [alertView show]; 97 | 98 | } 99 | 100 | @end 101 | -------------------------------------------------------------------------------- /GHContextMenu/GHCollectionViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // GHCollectionViewController.m 3 | // GHContextMenuDemo 4 | // 5 | // Created by Tapasya on 31/01/14. 6 | // Copyright (c) 2014 Tapasya. All rights reserved. 7 | // 8 | 9 | #import "GHCollectionViewController.h" 10 | #import "GHContextMenuView.h" 11 | 12 | @interface GHCollectionViewController () 13 | 14 | @end 15 | 16 | @implementation GHCollectionViewController 17 | 18 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 19 | { 20 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 21 | if (self) { 22 | // Custom initialization 23 | } 24 | return self; 25 | } 26 | 27 | - (void)viewDidLoad 28 | { 29 | [super viewDidLoad]; 30 | 31 | GHContextMenuView* overlay = [[GHContextMenuView alloc] init]; 32 | overlay.dataSource = self; 33 | overlay.delegate = self; 34 | 35 | // Do any additional setup after loading the view. 36 | // [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cell"]; 37 | UILongPressGestureRecognizer* _longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:overlay action:@selector(longPressDetected:)]; 38 | [self.collectionView addGestureRecognizer:_longPressRecognizer]; 39 | } 40 | 41 | - (void)didReceiveMemoryWarning 42 | { 43 | [super didReceiveMemoryWarning]; 44 | // Dispose of any resources that can be recreated. 45 | } 46 | 47 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section 48 | { 49 | return 18; 50 | } 51 | 52 | // The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath: 53 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 54 | { 55 | UICollectionViewCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath]; 56 | cell.contentView.backgroundColor = [UIColor grayColor]; 57 | UILabel* label = (UILabel*)[cell viewWithTag:100]; 58 | label.text = [NSString stringWithFormat:@"%ld",indexPath.row +1]; 59 | return cell; 60 | } 61 | 62 | -(UIEdgeInsets) collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section 63 | { 64 | return UIEdgeInsetsMake(10, 10, 10, 10); 65 | } 66 | 67 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath 68 | { 69 | return CGSizeMake(80, 120); 70 | } 71 | 72 | #pragma mark - GHMenu methods 73 | 74 | -(BOOL) shouldShowMenuAtPoint:(CGPoint)point 75 | { 76 | NSIndexPath* indexPath = [self.collectionView indexPathForItemAtPoint:point]; 77 | UICollectionViewCell* cell = [self.collectionView cellForItemAtIndexPath:indexPath]; 78 | 79 | return cell != nil; 80 | } 81 | 82 | - (NSInteger) numberOfMenuItems 83 | { 84 | return 3; 85 | } 86 | 87 | -(UIImage*) imageForItemAtIndex:(NSInteger)index 88 | { 89 | NSString* imageName = nil; 90 | switch (index) { 91 | case 0: 92 | imageName = @"facebook-white"; 93 | break; 94 | case 1: 95 | imageName = @"twitter-white"; 96 | break; 97 | case 2: 98 | imageName = @"google-plus-white"; 99 | break; 100 | case 3: 101 | imageName = @"linkedin-white"; 102 | break; 103 | case 4: 104 | imageName = @"pinterest-white"; 105 | break; 106 | 107 | default: 108 | break; 109 | } 110 | return [UIImage imageNamed:imageName]; 111 | } 112 | 113 | - (void) didSelectItemAtIndex:(NSInteger)selectedIndex forMenuAtPoint:(CGPoint)point 114 | { 115 | NSIndexPath* indexPath = [self.collectionView indexPathForItemAtPoint:point]; 116 | 117 | NSString* msg = nil; 118 | switch (selectedIndex) { 119 | case 0: 120 | msg = @"Facebook Selected"; 121 | break; 122 | case 1: 123 | msg = @"Twitter Selected"; 124 | break; 125 | case 2: 126 | msg = @"Google Plus Selected"; 127 | break; 128 | case 3: 129 | msg = @"Linkedin Selected"; 130 | break; 131 | case 4: 132 | msg = @"Pinterest Selected"; 133 | break; 134 | 135 | default: 136 | break; 137 | } 138 | 139 | msg = [msg stringByAppendingFormat:@" for cell %ld", (long)indexPath.row +1]; 140 | 141 | UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 142 | [alertView show]; 143 | 144 | } 145 | 146 | 147 | @end 148 | -------------------------------------------------------------------------------- /GHContextMenu/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 29 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /GHContextMenu/GHContextMenuView.m: -------------------------------------------------------------------------------- 1 | // 2 | // GHContextOverlayView.m 3 | // GHContextMenu 4 | // 5 | // Created by Tapasya on 27/01/14. 6 | // Copyright (c) 2014 Tapasya. All rights reserved. 7 | // 8 | 9 | #import "GHContextMenuView.h" 10 | 11 | #define GHShowAnimationID @"GHContextMenuViewRriseAnimationID" 12 | #define GHDismissAnimationID @"GHContextMenuViewDismissAnimationID" 13 | 14 | NSInteger const GHMainItemSize = 44; 15 | NSInteger const GHMenuItemSize = 40; 16 | NSInteger const GHBorderWidth = 5; 17 | 18 | CGFloat const GHAnimationDuration = 0.2; 19 | CGFloat const GHAnimationDelay = GHAnimationDuration/5; 20 | 21 | 22 | @interface GHMenuItemLocation : NSObject 23 | 24 | @property (nonatomic) CGPoint position; 25 | @property (nonatomic) CGFloat angle; 26 | 27 | @end 28 | 29 | @implementation GHMenuItemLocation 30 | 31 | @end 32 | 33 | 34 | @interface GHContextMenuView () 35 | { 36 | CADisplayLink *displayLink; 37 | } 38 | 39 | @property (nonatomic, strong) UILongPressGestureRecognizer* longPressRecognizer; 40 | 41 | @property (nonatomic, assign) BOOL isShowing; 42 | @property (nonatomic, assign) BOOL isPaning; 43 | 44 | @property (nonatomic) CGPoint longPressLocation; 45 | @property (nonatomic) CGPoint curretnLocation; 46 | 47 | @property (nonatomic, strong) NSMutableArray* menuItems; 48 | 49 | @property (nonatomic) CGFloat radius; 50 | @property (nonatomic) CGFloat arcAngle; 51 | @property (nonatomic) CGFloat angleBetweenItems; 52 | @property (nonatomic, strong) NSMutableArray* itemLocations; 53 | @property (nonatomic) NSInteger prevIndex; 54 | 55 | @property (nonatomic) CGColorRef itemBGHighlightedColor; 56 | @property (nonatomic) CGColorRef itemBGColor; 57 | 58 | @end 59 | 60 | @implementation GHContextMenuView 61 | 62 | - (id)init 63 | { 64 | self = [super initWithFrame:[[UIScreen mainScreen] bounds]]; 65 | if (self) { 66 | // Initialization code 67 | self.userInteractionEnabled = YES; 68 | // _longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressDetected:)]; 69 | // [self addGestureRecognizer:_longPressRecognizer]; 70 | self.backgroundColor = [UIColor clearColor]; 71 | 72 | // Default the menuActionType to Pan (original/default) 73 | _menuActionType = GHContextMenuActionTypePan; 74 | 75 | displayLink = [CADisplayLink displayLinkWithTarget:self 76 | selector:@selector(highlightMenuItemForPoint)]; 77 | 78 | [displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; 79 | 80 | _menuItems = [NSMutableArray array]; 81 | _itemLocations = [NSMutableArray array]; 82 | _arcAngle = M_PI_2; 83 | _radius = 90; 84 | 85 | self.itemBGColor = [UIColor grayColor].CGColor; 86 | self.itemBGHighlightedColor = [UIColor redColor].CGColor; 87 | 88 | } 89 | return self; 90 | } 91 | 92 | #pragma mark - 93 | #pragma mark Layer Touch Tracking 94 | #pragma mark - 95 | 96 | -(NSInteger)indexOfClosestMatchAtPoint:(CGPoint)point { 97 | int i = 0; 98 | for( CALayer *menuItemLayer in self.menuItems ) { 99 | if( CGRectContainsPoint( menuItemLayer.frame, point ) ) { 100 | NSLog( @"Touched Layer at index: %i", i); 101 | return i; 102 | } 103 | i++; 104 | } 105 | return -1; 106 | } 107 | 108 | 109 | -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 110 | 111 | CGPoint menuAtPoint = CGPointZero; 112 | 113 | if ([touches count] == 1) { 114 | 115 | UITouch *touch = (UITouch *)[touches anyObject]; 116 | CGPoint touchPoint = [touch locationInView:self]; 117 | 118 | NSInteger menuItemIndex = [self indexOfClosestMatchAtPoint:touchPoint]; 119 | if( menuItemIndex > -1 ) { 120 | menuAtPoint = [(CALayer *)self.menuItems[(NSUInteger)menuItemIndex] position]; 121 | } 122 | 123 | if( (self.prevIndex >= 0 && self.prevIndex != menuItemIndex)) { 124 | [self resetPreviousSelection]; 125 | } 126 | self.prevIndex = menuItemIndex; 127 | } 128 | 129 | [self dismissWithSelectedIndexForMenuAtPoint: menuAtPoint]; 130 | } 131 | 132 | 133 | #pragma mark - 134 | #pragma mark LongPress handler 135 | #pragma mark - 136 | 137 | // Split this out of the longPressDetected so that we can reuse it with touchesBegan (above) 138 | -(void)dismissWithSelectedIndexForMenuAtPoint:(CGPoint)point { 139 | 140 | if(self.delegate && [self.delegate respondsToSelector:@selector(didSelectItemAtIndex: forMenuAtPoint:)] && self.prevIndex >= 0){ 141 | [self.delegate didSelectItemAtIndex:self.prevIndex forMenuAtPoint:point]; 142 | self.prevIndex = -1; 143 | } 144 | 145 | [self hideMenu]; 146 | } 147 | 148 | - (void) longPressDetected:(UIGestureRecognizer*) gestureRecognizer 149 | { 150 | if (gestureRecognizer.state == UIGestureRecognizerStateBegan) { 151 | self.prevIndex = -1; 152 | 153 | CGPoint pointInView = [gestureRecognizer locationInView:gestureRecognizer.view]; 154 | if (self.dataSource != nil && [self.dataSource respondsToSelector:@selector(shouldShowMenuAtPoint:)] && ![self.dataSource shouldShowMenuAtPoint:pointInView]){ 155 | return; 156 | } 157 | 158 | [[UIApplication sharedApplication].keyWindow addSubview:self]; 159 | self.longPressLocation = [gestureRecognizer locationInView:self]; 160 | 161 | self.layer.backgroundColor = [UIColor colorWithWhite:0.1f alpha:.8f].CGColor; 162 | self.isShowing = YES; 163 | [self animateMenu:YES]; 164 | [self setNeedsDisplay]; 165 | } 166 | 167 | if (gestureRecognizer.state == UIGestureRecognizerStateChanged) { 168 | if (self.isShowing && self.menuActionType == GHContextMenuActionTypePan) { 169 | self.isPaning = YES; 170 | self.curretnLocation = [gestureRecognizer locationInView:self]; 171 | } 172 | } 173 | 174 | // Only trigger if we're using the GHContextMenuActionTypePan (default) 175 | if( gestureRecognizer.state == UIGestureRecognizerStateEnded && self.menuActionType == GHContextMenuActionTypePan ) { 176 | CGPoint menuAtPoint = [self convertPoint:self.longPressLocation toView:gestureRecognizer.view]; 177 | [self dismissWithSelectedIndexForMenuAtPoint:menuAtPoint]; 178 | } 179 | } 180 | 181 | - (void) showMenu 182 | { 183 | 184 | } 185 | 186 | - (void) hideMenu 187 | { 188 | if (self.isShowing) { 189 | self.layer.backgroundColor = [UIColor clearColor].CGColor; 190 | self.isShowing = NO; 191 | self.isPaning = NO; 192 | [self animateMenu:NO]; 193 | [self setNeedsDisplay]; 194 | [self removeFromSuperview]; 195 | } 196 | } 197 | 198 | - (CALayer*) layerWithImage:(UIImage*) image 199 | { 200 | CALayer *layer = [CALayer layer]; 201 | layer.bounds = CGRectMake(0, 0, GHMenuItemSize, GHMenuItemSize); 202 | layer.cornerRadius = GHMenuItemSize/2; 203 | layer.borderColor = [UIColor whiteColor].CGColor; 204 | layer.borderWidth = GHBorderWidth; 205 | layer.shadowColor = [UIColor blackColor].CGColor; 206 | layer.shadowOffset = CGSizeMake(0, -1); 207 | layer.backgroundColor = self.itemBGColor; 208 | 209 | CALayer* imageLayer = [CALayer layer]; 210 | imageLayer.contents = (id) image.CGImage; 211 | imageLayer.bounds = CGRectMake(0, 0, GHMenuItemSize*2/3, GHMenuItemSize*2/3); 212 | imageLayer.position = CGPointMake(GHMenuItemSize/2, GHMenuItemSize/2); 213 | [layer addSublayer:imageLayer]; 214 | 215 | return layer; 216 | } 217 | 218 | - (void) setDataSource:(id)dataSource 219 | { 220 | _dataSource = dataSource; 221 | [self reloadData]; 222 | 223 | } 224 | 225 | # pragma mark - menu item layout 226 | 227 | - (void) reloadData 228 | { 229 | [self.menuItems removeAllObjects]; 230 | [self.itemLocations removeAllObjects]; 231 | 232 | if (self.dataSource != nil) { 233 | NSInteger count = [self.dataSource numberOfMenuItems]; 234 | for (int i = 0; i < count; i++) { 235 | UIImage* image = [self.dataSource imageForItemAtIndex:i]; 236 | CALayer *layer = [self layerWithImage:image]; 237 | [self.layer addSublayer:layer]; 238 | [self.menuItems addObject:layer]; 239 | } 240 | } 241 | } 242 | 243 | - (void) layoutMenuItems 244 | { 245 | [self.itemLocations removeAllObjects]; 246 | 247 | CGSize itemSize = CGSizeMake(GHMenuItemSize, GHMenuItemSize); 248 | CGFloat itemRadius = sqrt(pow(itemSize.width, 2) + pow(itemSize.height, 2)) / 2; 249 | self.arcAngle = ((itemRadius * self.menuItems.count) / self.radius) * 1.5; 250 | 251 | NSUInteger count = self.menuItems.count; 252 | BOOL isFullCircle = (self.arcAngle == M_PI*2); 253 | NSUInteger divisor = (isFullCircle) ? count : count - 1; 254 | 255 | self.angleBetweenItems = self.arcAngle/divisor; 256 | 257 | for (int i = 0; i < self.menuItems.count; i++) { 258 | GHMenuItemLocation *location = [self locationForItemAtIndex:i]; 259 | [self.itemLocations addObject:location]; 260 | 261 | CALayer* layer = (CALayer*) [self.menuItems objectAtIndex:i]; 262 | layer.transform = CATransform3DIdentity; 263 | 264 | // Rotate menu items based on orientation 265 | if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) { 266 | CGFloat angle = [UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeLeft ? M_PI_2 : -M_PI_2; 267 | layer.transform = CATransform3DRotate(CATransform3DIdentity, angle, 0, 0, 1); 268 | } 269 | } 270 | } 271 | 272 | - (GHMenuItemLocation*) locationForItemAtIndex:(NSUInteger) index 273 | { 274 | CGFloat itemAngle = [self itemAngleAtIndex:index]; 275 | 276 | CGPoint itemCenter = CGPointMake(self.longPressLocation.x + cosf(itemAngle) * self.radius, 277 | self.longPressLocation.y + sinf(itemAngle) * self.radius); 278 | GHMenuItemLocation *location = [GHMenuItemLocation new]; 279 | location.position = itemCenter; 280 | location.angle = itemAngle; 281 | 282 | return location; 283 | } 284 | 285 | - (CGFloat) itemAngleAtIndex:(NSUInteger) index 286 | { 287 | float bearingRadians = [self angleBeweenStartinPoint:self.longPressLocation endingPoint:self.center]; 288 | 289 | CGFloat angle = bearingRadians - self.arcAngle/2; 290 | 291 | CGFloat itemAngle = angle + (index * self.angleBetweenItems); 292 | 293 | if (itemAngle > 2 *M_PI) { 294 | itemAngle -= 2*M_PI; 295 | }else if (itemAngle < 0){ 296 | itemAngle += 2*M_PI; 297 | } 298 | 299 | return itemAngle; 300 | } 301 | 302 | # pragma mark - helper methiods 303 | 304 | - (CGFloat) calculateRadius 305 | { 306 | CGSize mainSize = CGSizeMake(GHMainItemSize, GHMainItemSize); 307 | CGSize itemSize = CGSizeMake(GHMenuItemSize, GHMenuItemSize); 308 | CGFloat mainRadius = sqrt(pow(mainSize.width, 2) + pow(mainSize.height, 2)) / 2; 309 | CGFloat itemRadius = sqrt(pow(itemSize.width, 2) + pow(itemSize.height, 2)) / 2; 310 | 311 | CGFloat minRadius = (CGFloat)(mainRadius + itemRadius); 312 | CGFloat maxRadius = ((itemRadius * self.menuItems.count) / self.arcAngle) * 1.5; 313 | 314 | CGFloat radius = MAX(minRadius, maxRadius); 315 | 316 | return radius; 317 | } 318 | 319 | - (CGFloat) angleBeweenStartinPoint:(CGPoint) startingPoint endingPoint:(CGPoint) endingPoint 320 | { 321 | CGPoint originPoint = CGPointMake(endingPoint.x - startingPoint.x, endingPoint.y - startingPoint.y); 322 | float bearingRadians = atan2f(originPoint.y, originPoint.x); 323 | 324 | bearingRadians = (bearingRadians > 0.0 ? bearingRadians : (M_PI*2 + bearingRadians)); 325 | 326 | return bearingRadians; 327 | } 328 | 329 | - (CGFloat) validaAngle:(CGFloat) angle 330 | { 331 | if (angle > 2*M_PI) { 332 | angle = [self validaAngle:angle - 2*M_PI]; 333 | } 334 | 335 | return angle; 336 | } 337 | 338 | # pragma mark - animation and selection 339 | 340 | - (void) highlightMenuItemForPoint 341 | { 342 | if (self.isShowing && self.isPaning) { 343 | 344 | CGFloat angle = [self angleBeweenStartinPoint:self.longPressLocation endingPoint:self.curretnLocation]; 345 | NSInteger closeToIndex = -1; 346 | for (int i = 0; i < self.menuItems.count; i++) { 347 | GHMenuItemLocation* itemLocation = [self.itemLocations objectAtIndex:i]; 348 | if (fabs(itemLocation.angle - angle) < self.angleBetweenItems/2) { 349 | closeToIndex = i; 350 | break; 351 | } 352 | } 353 | 354 | if (closeToIndex >= 0 && closeToIndex < self.menuItems.count) { 355 | 356 | GHMenuItemLocation* itemLocation = [self.itemLocations objectAtIndex:closeToIndex]; 357 | 358 | CGFloat distanceFromCenter = sqrt(pow(self.curretnLocation.x - self.longPressLocation.x, 2)+ pow(self.curretnLocation.y-self.longPressLocation.y, 2)); 359 | 360 | CGFloat toleranceDistance = (self.radius - GHMainItemSize/(2*sqrt(2)) - GHMenuItemSize/(2*sqrt(2)) )/2; 361 | 362 | CGFloat distanceFromItem = fabsf(distanceFromCenter - self.radius) - GHMenuItemSize/(2*sqrt(2)) ; 363 | 364 | if (fabs(distanceFromItem) < toleranceDistance ) { 365 | CALayer *layer = [self.menuItems objectAtIndex:closeToIndex]; 366 | layer.backgroundColor = self.itemBGHighlightedColor; 367 | 368 | CGFloat distanceFromItemBorder = fabs(distanceFromItem); 369 | 370 | CGFloat scaleFactor = 1 + 0.5 *(1-distanceFromItemBorder/toleranceDistance) ; 371 | 372 | if (scaleFactor < 1.0) { 373 | scaleFactor = 1.0; 374 | } 375 | 376 | // Scale 377 | CATransform3D scaleTransForm = CATransform3DScale(CATransform3DIdentity, scaleFactor, scaleFactor, 1.0); 378 | 379 | CGFloat xtrans = cosf(itemLocation.angle); 380 | CGFloat ytrans = sinf(itemLocation.angle); 381 | 382 | CATransform3D transLate = CATransform3DTranslate(scaleTransForm, 10*scaleFactor*xtrans, 10*scaleFactor*ytrans, 0); 383 | layer.transform = transLate; 384 | 385 | if ( ( self.prevIndex >= 0 && self.prevIndex != closeToIndex)) { 386 | [self resetPreviousSelection]; 387 | } 388 | 389 | self.prevIndex = closeToIndex; 390 | 391 | } else if(self.prevIndex >= 0) { 392 | [self resetPreviousSelection]; 393 | } 394 | }else { 395 | [self resetPreviousSelection]; 396 | } 397 | } 398 | } 399 | 400 | - (void) resetPreviousSelection 401 | { 402 | if (self.prevIndex >= 0) { 403 | CALayer *layer = self.menuItems[self.prevIndex]; 404 | GHMenuItemLocation* itemLocation = [self.itemLocations objectAtIndex:self.prevIndex]; 405 | layer.position = itemLocation.position; 406 | layer.backgroundColor = self.itemBGColor; 407 | layer.transform = CATransform3DIdentity; 408 | self.prevIndex = -1; 409 | } 410 | } 411 | 412 | - (void) animateMenu:(BOOL) isShowing 413 | { 414 | if (isShowing) { 415 | [self layoutMenuItems]; 416 | } 417 | 418 | for (NSUInteger index = 0; index < self.menuItems.count; index++) { 419 | CALayer *layer = self.menuItems[index]; 420 | layer.opacity = 0; 421 | CGPoint fromPosition = self.longPressLocation; 422 | 423 | GHMenuItemLocation* location = [self.itemLocations objectAtIndex:index]; 424 | CGPoint toPosition = location.position; 425 | 426 | double delayInSeconds = index * GHAnimationDelay; 427 | 428 | CABasicAnimation *positionAnimation; 429 | 430 | positionAnimation = [CABasicAnimation animationWithKeyPath:@"position"]; 431 | positionAnimation.fromValue = [NSValue valueWithCGPoint:isShowing ? fromPosition : toPosition]; 432 | positionAnimation.toValue = [NSValue valueWithCGPoint:isShowing ? toPosition : fromPosition]; 433 | positionAnimation.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.45f :1.2f :0.75f :1.0f]; 434 | positionAnimation.duration = GHAnimationDuration; 435 | positionAnimation.beginTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil] + delayInSeconds; 436 | [positionAnimation setValue:[NSNumber numberWithUnsignedInteger:index] forKey:isShowing ? GHShowAnimationID : GHDismissAnimationID]; 437 | positionAnimation.delegate = self; 438 | 439 | [layer addAnimation:positionAnimation forKey:@"riseAnimation"]; 440 | } 441 | } 442 | 443 | - (void)animationDidStart:(CAAnimation *)anim 444 | { 445 | if([anim valueForKey:GHShowAnimationID]) { 446 | NSUInteger index = [[anim valueForKey:GHShowAnimationID] unsignedIntegerValue]; 447 | CALayer *layer = self.menuItems[index]; 448 | 449 | GHMenuItemLocation* location = [self.itemLocations objectAtIndex:index]; 450 | CGFloat toAlpha = 1.0; 451 | 452 | layer.position = location.position; 453 | layer.opacity = toAlpha; 454 | 455 | } 456 | else if([anim valueForKey:GHDismissAnimationID]) { 457 | NSUInteger index = [[anim valueForKey:GHDismissAnimationID] unsignedIntegerValue]; 458 | CALayer *layer = self.menuItems[index]; 459 | CGPoint toPosition = self.longPressLocation; 460 | [CATransaction begin]; 461 | [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; 462 | layer.position = toPosition; 463 | layer.backgroundColor = self.itemBGColor; 464 | layer.opacity = 0.0f; 465 | layer.transform = CATransform3DIdentity; 466 | [CATransaction commit]; 467 | } 468 | } 469 | 470 | - (void)drawCircle:(CGPoint)locationOfTouch 471 | { 472 | CGContextRef ctx= UIGraphicsGetCurrentContext(); 473 | CGContextSaveGState(ctx); 474 | CGContextSetLineWidth(ctx,GHBorderWidth/2); 475 | CGContextSetRGBStrokeColor(ctx,0.8,0.8,0.8,1.0); 476 | CGContextAddArc(ctx,locationOfTouch.x,locationOfTouch.y,GHMainItemSize/2,0.0,M_PI*2,YES); 477 | CGContextStrokePath(ctx); 478 | } 479 | 480 | // Only override drawRect: if you perform custom drawing. 481 | // An empty implementation adversely affects performance during animation. 482 | - (void)drawRect:(CGRect)rect 483 | { 484 | // Drawing code 485 | if (self.isShowing) { 486 | [self drawCircle:self.longPressLocation]; 487 | } 488 | } 489 | @end 490 | -------------------------------------------------------------------------------- /GHContextMenuDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 84EF2A4D189A298E0089D32D /* facebook-white@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 84EF2A43189A298E0089D32D /* facebook-white@2x.png */; }; 11 | 84EF2A4E189A298E0089D32D /* google-plus-white@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 84EF2A44189A298E0089D32D /* google-plus-white@2x.png */; }; 12 | 84EF2A4F189A298E0089D32D /* linkedin-white@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 84EF2A45189A298E0089D32D /* linkedin-white@2x.png */; }; 13 | 84EF2A50189A298E0089D32D /* pinterest-white@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 84EF2A46189A298E0089D32D /* pinterest-white@2x.png */; }; 14 | 84EF2A51189A298E0089D32D /* twitter-white@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 84EF2A47189A298E0089D32D /* twitter-white@2x.png */; }; 15 | 84EF2A52189A298E0089D32D /* facebook-white.png in Resources */ = {isa = PBXBuildFile; fileRef = 84EF2A48189A298E0089D32D /* facebook-white.png */; }; 16 | 84EF2A53189A298E0089D32D /* google-plus-white.png in Resources */ = {isa = PBXBuildFile; fileRef = 84EF2A49189A298E0089D32D /* google-plus-white.png */; }; 17 | 84EF2A54189A298E0089D32D /* linkedin-white.png in Resources */ = {isa = PBXBuildFile; fileRef = 84EF2A4A189A298E0089D32D /* linkedin-white.png */; }; 18 | 84EF2A55189A298E0089D32D /* pinterest-white.png in Resources */ = {isa = PBXBuildFile; fileRef = 84EF2A4B189A298E0089D32D /* pinterest-white.png */; }; 19 | 84EF2A56189A298E0089D32D /* twitter-white.png in Resources */ = {isa = PBXBuildFile; fileRef = 84EF2A4C189A298E0089D32D /* twitter-white.png */; }; 20 | 84EF2A5D189BAF730089D32D /* GHCollectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84EF2A5C189BAF730089D32D /* GHCollectionViewController.m */; }; 21 | 84F0C30718962C3F00870008 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84F0C30618962C3F00870008 /* Foundation.framework */; }; 22 | 84F0C30918962C3F00870008 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84F0C30818962C3F00870008 /* CoreGraphics.framework */; }; 23 | 84F0C30B18962C3F00870008 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84F0C30A18962C3F00870008 /* UIKit.framework */; }; 24 | 84F0C31118962C3F00870008 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 84F0C30F18962C3F00870008 /* InfoPlist.strings */; }; 25 | 84F0C31318962C3F00870008 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F0C31218962C3F00870008 /* main.m */; }; 26 | 84F0C31718962C3F00870008 /* GHAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F0C31618962C3F00870008 /* GHAppDelegate.m */; }; 27 | 84F0C31A18962C3F00870008 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 84F0C31818962C3F00870008 /* Main.storyboard */; }; 28 | 84F0C31D18962C3F00870008 /* GHViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F0C31C18962C3F00870008 /* GHViewController.m */; }; 29 | 84F0C31F18962C3F00870008 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 84F0C31E18962C3F00870008 /* Images.xcassets */; }; 30 | 84F0C32618962C3F00870008 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84F0C32518962C3F00870008 /* XCTest.framework */; }; 31 | 84F0C32718962C3F00870008 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84F0C30618962C3F00870008 /* Foundation.framework */; }; 32 | 84F0C32818962C3F00870008 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84F0C30A18962C3F00870008 /* UIKit.framework */; }; 33 | 84F0C33018962C3F00870008 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 84F0C32E18962C3F00870008 /* InfoPlist.strings */; }; 34 | 84F0C33218962C3F00870008 /* GHContextMenuTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F0C33118962C3F00870008 /* GHContextMenuTests.m */; }; 35 | 84F0C33E18965E5700870008 /* GHContextMenuView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F0C33D18965E5700870008 /* GHContextMenuView.m */; }; 36 | 84F0C3401896617200870008 /* twitter.png in Resources */ = {isa = PBXBuildFile; fileRef = 84F0C33F1896617200870008 /* twitter.png */; }; 37 | /* End PBXBuildFile section */ 38 | 39 | /* Begin PBXContainerItemProxy section */ 40 | 84F0C32918962C3F00870008 /* PBXContainerItemProxy */ = { 41 | isa = PBXContainerItemProxy; 42 | containerPortal = 84F0C2FB18962C3F00870008 /* Project object */; 43 | proxyType = 1; 44 | remoteGlobalIDString = 84F0C30218962C3F00870008; 45 | remoteInfo = GHContextMenu; 46 | }; 47 | /* End PBXContainerItemProxy section */ 48 | 49 | /* Begin PBXFileReference section */ 50 | 84EF2A43189A298E0089D32D /* facebook-white@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "facebook-white@2x.png"; sourceTree = ""; }; 51 | 84EF2A44189A298E0089D32D /* google-plus-white@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "google-plus-white@2x.png"; sourceTree = ""; }; 52 | 84EF2A45189A298E0089D32D /* linkedin-white@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "linkedin-white@2x.png"; sourceTree = ""; }; 53 | 84EF2A46189A298E0089D32D /* pinterest-white@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "pinterest-white@2x.png"; sourceTree = ""; }; 54 | 84EF2A47189A298E0089D32D /* twitter-white@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "twitter-white@2x.png"; sourceTree = ""; }; 55 | 84EF2A48189A298E0089D32D /* facebook-white.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "facebook-white.png"; sourceTree = ""; }; 56 | 84EF2A49189A298E0089D32D /* google-plus-white.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "google-plus-white.png"; sourceTree = ""; }; 57 | 84EF2A4A189A298E0089D32D /* linkedin-white.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "linkedin-white.png"; sourceTree = ""; }; 58 | 84EF2A4B189A298E0089D32D /* pinterest-white.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "pinterest-white.png"; sourceTree = ""; }; 59 | 84EF2A4C189A298E0089D32D /* twitter-white.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "twitter-white.png"; sourceTree = ""; }; 60 | 84EF2A5B189BAF730089D32D /* GHCollectionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHCollectionViewController.h; sourceTree = ""; }; 61 | 84EF2A5C189BAF730089D32D /* GHCollectionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHCollectionViewController.m; sourceTree = ""; }; 62 | 84F0C30318962C3F00870008 /* GHContextMenu.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GHContextMenu.app; sourceTree = BUILT_PRODUCTS_DIR; }; 63 | 84F0C30618962C3F00870008 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 64 | 84F0C30818962C3F00870008 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 65 | 84F0C30A18962C3F00870008 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 66 | 84F0C30E18962C3F00870008 /* GHContextMenu-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GHContextMenu-Info.plist"; sourceTree = ""; }; 67 | 84F0C31018962C3F00870008 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 68 | 84F0C31218962C3F00870008 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 69 | 84F0C31418962C3F00870008 /* GHContextMenu-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GHContextMenu-Prefix.pch"; sourceTree = ""; }; 70 | 84F0C31518962C3F00870008 /* GHAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GHAppDelegate.h; sourceTree = ""; }; 71 | 84F0C31618962C3F00870008 /* GHAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GHAppDelegate.m; sourceTree = ""; }; 72 | 84F0C31918962C3F00870008 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 73 | 84F0C31B18962C3F00870008 /* GHViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GHViewController.h; sourceTree = ""; }; 74 | 84F0C31C18962C3F00870008 /* GHViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GHViewController.m; sourceTree = ""; }; 75 | 84F0C31E18962C3F00870008 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 76 | 84F0C32418962C3F00870008 /* GHContextMenuTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GHContextMenuTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 77 | 84F0C32518962C3F00870008 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 78 | 84F0C32D18962C3F00870008 /* GHContextMenuTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GHContextMenuTests-Info.plist"; sourceTree = ""; }; 79 | 84F0C32F18962C3F00870008 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 80 | 84F0C33118962C3F00870008 /* GHContextMenuTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GHContextMenuTests.m; sourceTree = ""; }; 81 | 84F0C33C18965E5700870008 /* GHContextMenuView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GHContextMenuView.h; sourceTree = ""; }; 82 | 84F0C33D18965E5700870008 /* GHContextMenuView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHContextMenuView.m; sourceTree = ""; }; 83 | 84F0C33F1896617200870008 /* twitter.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = twitter.png; sourceTree = ""; }; 84 | /* End PBXFileReference section */ 85 | 86 | /* Begin PBXFrameworksBuildPhase section */ 87 | 84F0C30018962C3F00870008 /* Frameworks */ = { 88 | isa = PBXFrameworksBuildPhase; 89 | buildActionMask = 2147483647; 90 | files = ( 91 | 84F0C30918962C3F00870008 /* CoreGraphics.framework in Frameworks */, 92 | 84F0C30B18962C3F00870008 /* UIKit.framework in Frameworks */, 93 | 84F0C30718962C3F00870008 /* Foundation.framework in Frameworks */, 94 | ); 95 | runOnlyForDeploymentPostprocessing = 0; 96 | }; 97 | 84F0C32118962C3F00870008 /* Frameworks */ = { 98 | isa = PBXFrameworksBuildPhase; 99 | buildActionMask = 2147483647; 100 | files = ( 101 | 84F0C32618962C3F00870008 /* XCTest.framework in Frameworks */, 102 | 84F0C32818962C3F00870008 /* UIKit.framework in Frameworks */, 103 | 84F0C32718962C3F00870008 /* Foundation.framework in Frameworks */, 104 | ); 105 | runOnlyForDeploymentPostprocessing = 0; 106 | }; 107 | /* End PBXFrameworksBuildPhase section */ 108 | 109 | /* Begin PBXGroup section */ 110 | 84EF2A42189A29790089D32D /* Menu images */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | 84EF2A43189A298E0089D32D /* facebook-white@2x.png */, 114 | 84EF2A44189A298E0089D32D /* google-plus-white@2x.png */, 115 | 84EF2A45189A298E0089D32D /* linkedin-white@2x.png */, 116 | 84EF2A46189A298E0089D32D /* pinterest-white@2x.png */, 117 | 84EF2A47189A298E0089D32D /* twitter-white@2x.png */, 118 | 84EF2A48189A298E0089D32D /* facebook-white.png */, 119 | 84EF2A49189A298E0089D32D /* google-plus-white.png */, 120 | 84EF2A4A189A298E0089D32D /* linkedin-white.png */, 121 | 84EF2A4B189A298E0089D32D /* pinterest-white.png */, 122 | 84EF2A4C189A298E0089D32D /* twitter-white.png */, 123 | ); 124 | name = "Menu images"; 125 | sourceTree = ""; 126 | }; 127 | 84F0C2FA18962C3F00870008 = { 128 | isa = PBXGroup; 129 | children = ( 130 | 84F0C30C18962C3F00870008 /* GHContextMenu */, 131 | 84F0C32B18962C3F00870008 /* GHContextMenuTests */, 132 | 84F0C30518962C3F00870008 /* Frameworks */, 133 | 84F0C30418962C3F00870008 /* Products */, 134 | ); 135 | sourceTree = ""; 136 | }; 137 | 84F0C30418962C3F00870008 /* Products */ = { 138 | isa = PBXGroup; 139 | children = ( 140 | 84F0C30318962C3F00870008 /* GHContextMenu.app */, 141 | 84F0C32418962C3F00870008 /* GHContextMenuTests.xctest */, 142 | ); 143 | name = Products; 144 | sourceTree = ""; 145 | }; 146 | 84F0C30518962C3F00870008 /* Frameworks */ = { 147 | isa = PBXGroup; 148 | children = ( 149 | 84F0C30618962C3F00870008 /* Foundation.framework */, 150 | 84F0C30818962C3F00870008 /* CoreGraphics.framework */, 151 | 84F0C30A18962C3F00870008 /* UIKit.framework */, 152 | 84F0C32518962C3F00870008 /* XCTest.framework */, 153 | ); 154 | name = Frameworks; 155 | sourceTree = ""; 156 | }; 157 | 84F0C30C18962C3F00870008 /* GHContextMenu */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | 84F0C33B18962C5100870008 /* ContextMenu */, 161 | 84F0C31518962C3F00870008 /* GHAppDelegate.h */, 162 | 84F0C31618962C3F00870008 /* GHAppDelegate.m */, 163 | 84F0C31818962C3F00870008 /* Main.storyboard */, 164 | 84F0C31B18962C3F00870008 /* GHViewController.h */, 165 | 84F0C31C18962C3F00870008 /* GHViewController.m */, 166 | 84EF2A5B189BAF730089D32D /* GHCollectionViewController.h */, 167 | 84EF2A5C189BAF730089D32D /* GHCollectionViewController.m */, 168 | 84F0C31E18962C3F00870008 /* Images.xcassets */, 169 | 84F0C30D18962C3F00870008 /* Supporting Files */, 170 | ); 171 | path = GHContextMenu; 172 | sourceTree = ""; 173 | }; 174 | 84F0C30D18962C3F00870008 /* Supporting Files */ = { 175 | isa = PBXGroup; 176 | children = ( 177 | 84F0C33F1896617200870008 /* twitter.png */, 178 | 84EF2A42189A29790089D32D /* Menu images */, 179 | 84F0C30E18962C3F00870008 /* GHContextMenu-Info.plist */, 180 | 84F0C30F18962C3F00870008 /* InfoPlist.strings */, 181 | 84F0C31218962C3F00870008 /* main.m */, 182 | 84F0C31418962C3F00870008 /* GHContextMenu-Prefix.pch */, 183 | ); 184 | name = "Supporting Files"; 185 | sourceTree = ""; 186 | }; 187 | 84F0C32B18962C3F00870008 /* GHContextMenuTests */ = { 188 | isa = PBXGroup; 189 | children = ( 190 | 84F0C33118962C3F00870008 /* GHContextMenuTests.m */, 191 | 84F0C32C18962C3F00870008 /* Supporting Files */, 192 | ); 193 | path = GHContextMenuTests; 194 | sourceTree = ""; 195 | }; 196 | 84F0C32C18962C3F00870008 /* Supporting Files */ = { 197 | isa = PBXGroup; 198 | children = ( 199 | 84F0C32D18962C3F00870008 /* GHContextMenuTests-Info.plist */, 200 | 84F0C32E18962C3F00870008 /* InfoPlist.strings */, 201 | ); 202 | name = "Supporting Files"; 203 | sourceTree = ""; 204 | }; 205 | 84F0C33B18962C5100870008 /* ContextMenu */ = { 206 | isa = PBXGroup; 207 | children = ( 208 | 84F0C33C18965E5700870008 /* GHContextMenuView.h */, 209 | 84F0C33D18965E5700870008 /* GHContextMenuView.m */, 210 | ); 211 | name = ContextMenu; 212 | sourceTree = ""; 213 | }; 214 | /* End PBXGroup section */ 215 | 216 | /* Begin PBXNativeTarget section */ 217 | 84F0C30218962C3F00870008 /* GHContextMenu */ = { 218 | isa = PBXNativeTarget; 219 | buildConfigurationList = 84F0C33518962C3F00870008 /* Build configuration list for PBXNativeTarget "GHContextMenu" */; 220 | buildPhases = ( 221 | 84F0C2FF18962C3F00870008 /* Sources */, 222 | 84F0C30018962C3F00870008 /* Frameworks */, 223 | 84F0C30118962C3F00870008 /* Resources */, 224 | ); 225 | buildRules = ( 226 | ); 227 | dependencies = ( 228 | ); 229 | name = GHContextMenu; 230 | productName = GHContextMenu; 231 | productReference = 84F0C30318962C3F00870008 /* GHContextMenu.app */; 232 | productType = "com.apple.product-type.application"; 233 | }; 234 | 84F0C32318962C3F00870008 /* GHContextMenuTests */ = { 235 | isa = PBXNativeTarget; 236 | buildConfigurationList = 84F0C33818962C3F00870008 /* Build configuration list for PBXNativeTarget "GHContextMenuTests" */; 237 | buildPhases = ( 238 | 84F0C32018962C3F00870008 /* Sources */, 239 | 84F0C32118962C3F00870008 /* Frameworks */, 240 | 84F0C32218962C3F00870008 /* Resources */, 241 | ); 242 | buildRules = ( 243 | ); 244 | dependencies = ( 245 | 84F0C32A18962C3F00870008 /* PBXTargetDependency */, 246 | ); 247 | name = GHContextMenuTests; 248 | productName = GHContextMenuTests; 249 | productReference = 84F0C32418962C3F00870008 /* GHContextMenuTests.xctest */; 250 | productType = "com.apple.product-type.bundle.unit-test"; 251 | }; 252 | /* End PBXNativeTarget section */ 253 | 254 | /* Begin PBXProject section */ 255 | 84F0C2FB18962C3F00870008 /* Project object */ = { 256 | isa = PBXProject; 257 | attributes = { 258 | CLASSPREFIX = GH; 259 | LastUpgradeCheck = 0500; 260 | ORGANIZATIONNAME = Tapasya; 261 | TargetAttributes = { 262 | 84F0C32318962C3F00870008 = { 263 | TestTargetID = 84F0C30218962C3F00870008; 264 | }; 265 | }; 266 | }; 267 | buildConfigurationList = 84F0C2FE18962C3F00870008 /* Build configuration list for PBXProject "GHContextMenuDemo" */; 268 | compatibilityVersion = "Xcode 3.2"; 269 | developmentRegion = English; 270 | hasScannedForEncodings = 0; 271 | knownRegions = ( 272 | en, 273 | Base, 274 | ); 275 | mainGroup = 84F0C2FA18962C3F00870008; 276 | productRefGroup = 84F0C30418962C3F00870008 /* Products */; 277 | projectDirPath = ""; 278 | projectRoot = ""; 279 | targets = ( 280 | 84F0C30218962C3F00870008 /* GHContextMenu */, 281 | 84F0C32318962C3F00870008 /* GHContextMenuTests */, 282 | ); 283 | }; 284 | /* End PBXProject section */ 285 | 286 | /* Begin PBXResourcesBuildPhase section */ 287 | 84F0C30118962C3F00870008 /* Resources */ = { 288 | isa = PBXResourcesBuildPhase; 289 | buildActionMask = 2147483647; 290 | files = ( 291 | 84EF2A4F189A298E0089D32D /* linkedin-white@2x.png in Resources */, 292 | 84EF2A53189A298E0089D32D /* google-plus-white.png in Resources */, 293 | 84EF2A52189A298E0089D32D /* facebook-white.png in Resources */, 294 | 84F0C31F18962C3F00870008 /* Images.xcassets in Resources */, 295 | 84F0C3401896617200870008 /* twitter.png in Resources */, 296 | 84EF2A54189A298E0089D32D /* linkedin-white.png in Resources */, 297 | 84EF2A4D189A298E0089D32D /* facebook-white@2x.png in Resources */, 298 | 84EF2A55189A298E0089D32D /* pinterest-white.png in Resources */, 299 | 84EF2A51189A298E0089D32D /* twitter-white@2x.png in Resources */, 300 | 84EF2A4E189A298E0089D32D /* google-plus-white@2x.png in Resources */, 301 | 84F0C31118962C3F00870008 /* InfoPlist.strings in Resources */, 302 | 84EF2A56189A298E0089D32D /* twitter-white.png in Resources */, 303 | 84F0C31A18962C3F00870008 /* Main.storyboard in Resources */, 304 | 84EF2A50189A298E0089D32D /* pinterest-white@2x.png in Resources */, 305 | ); 306 | runOnlyForDeploymentPostprocessing = 0; 307 | }; 308 | 84F0C32218962C3F00870008 /* Resources */ = { 309 | isa = PBXResourcesBuildPhase; 310 | buildActionMask = 2147483647; 311 | files = ( 312 | 84F0C33018962C3F00870008 /* InfoPlist.strings in Resources */, 313 | ); 314 | runOnlyForDeploymentPostprocessing = 0; 315 | }; 316 | /* End PBXResourcesBuildPhase section */ 317 | 318 | /* Begin PBXSourcesBuildPhase section */ 319 | 84F0C2FF18962C3F00870008 /* Sources */ = { 320 | isa = PBXSourcesBuildPhase; 321 | buildActionMask = 2147483647; 322 | files = ( 323 | 84F0C31318962C3F00870008 /* main.m in Sources */, 324 | 84F0C31D18962C3F00870008 /* GHViewController.m in Sources */, 325 | 84EF2A5D189BAF730089D32D /* GHCollectionViewController.m in Sources */, 326 | 84F0C33E18965E5700870008 /* GHContextMenuView.m in Sources */, 327 | 84F0C31718962C3F00870008 /* GHAppDelegate.m in Sources */, 328 | ); 329 | runOnlyForDeploymentPostprocessing = 0; 330 | }; 331 | 84F0C32018962C3F00870008 /* Sources */ = { 332 | isa = PBXSourcesBuildPhase; 333 | buildActionMask = 2147483647; 334 | files = ( 335 | 84F0C33218962C3F00870008 /* GHContextMenuTests.m in Sources */, 336 | ); 337 | runOnlyForDeploymentPostprocessing = 0; 338 | }; 339 | /* End PBXSourcesBuildPhase section */ 340 | 341 | /* Begin PBXTargetDependency section */ 342 | 84F0C32A18962C3F00870008 /* PBXTargetDependency */ = { 343 | isa = PBXTargetDependency; 344 | target = 84F0C30218962C3F00870008 /* GHContextMenu */; 345 | targetProxy = 84F0C32918962C3F00870008 /* PBXContainerItemProxy */; 346 | }; 347 | /* End PBXTargetDependency section */ 348 | 349 | /* Begin PBXVariantGroup section */ 350 | 84F0C30F18962C3F00870008 /* InfoPlist.strings */ = { 351 | isa = PBXVariantGroup; 352 | children = ( 353 | 84F0C31018962C3F00870008 /* en */, 354 | ); 355 | name = InfoPlist.strings; 356 | sourceTree = ""; 357 | }; 358 | 84F0C31818962C3F00870008 /* Main.storyboard */ = { 359 | isa = PBXVariantGroup; 360 | children = ( 361 | 84F0C31918962C3F00870008 /* Base */, 362 | ); 363 | name = Main.storyboard; 364 | sourceTree = ""; 365 | }; 366 | 84F0C32E18962C3F00870008 /* InfoPlist.strings */ = { 367 | isa = PBXVariantGroup; 368 | children = ( 369 | 84F0C32F18962C3F00870008 /* en */, 370 | ); 371 | name = InfoPlist.strings; 372 | sourceTree = ""; 373 | }; 374 | /* End PBXVariantGroup section */ 375 | 376 | /* Begin XCBuildConfiguration section */ 377 | 84F0C33318962C3F00870008 /* Debug */ = { 378 | isa = XCBuildConfiguration; 379 | buildSettings = { 380 | ALWAYS_SEARCH_USER_PATHS = NO; 381 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 382 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 383 | CLANG_CXX_LIBRARY = "libc++"; 384 | CLANG_ENABLE_MODULES = YES; 385 | CLANG_ENABLE_OBJC_ARC = YES; 386 | CLANG_WARN_BOOL_CONVERSION = YES; 387 | CLANG_WARN_CONSTANT_CONVERSION = YES; 388 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 389 | CLANG_WARN_EMPTY_BODY = YES; 390 | CLANG_WARN_ENUM_CONVERSION = YES; 391 | CLANG_WARN_INT_CONVERSION = YES; 392 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 393 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 394 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 395 | COPY_PHASE_STRIP = NO; 396 | GCC_C_LANGUAGE_STANDARD = gnu99; 397 | GCC_DYNAMIC_NO_PIC = NO; 398 | GCC_OPTIMIZATION_LEVEL = 0; 399 | GCC_PREPROCESSOR_DEFINITIONS = ( 400 | "DEBUG=1", 401 | "$(inherited)", 402 | ); 403 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 404 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 405 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 406 | GCC_WARN_UNDECLARED_SELECTOR = YES; 407 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 408 | GCC_WARN_UNUSED_FUNCTION = YES; 409 | GCC_WARN_UNUSED_VARIABLE = YES; 410 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 411 | ONLY_ACTIVE_ARCH = YES; 412 | SDKROOT = iphoneos; 413 | }; 414 | name = Debug; 415 | }; 416 | 84F0C33418962C3F00870008 /* Release */ = { 417 | isa = XCBuildConfiguration; 418 | buildSettings = { 419 | ALWAYS_SEARCH_USER_PATHS = NO; 420 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 421 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 422 | CLANG_CXX_LIBRARY = "libc++"; 423 | CLANG_ENABLE_MODULES = YES; 424 | CLANG_ENABLE_OBJC_ARC = YES; 425 | CLANG_WARN_BOOL_CONVERSION = YES; 426 | CLANG_WARN_CONSTANT_CONVERSION = YES; 427 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 428 | CLANG_WARN_EMPTY_BODY = YES; 429 | CLANG_WARN_ENUM_CONVERSION = YES; 430 | CLANG_WARN_INT_CONVERSION = YES; 431 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 432 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 433 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 434 | COPY_PHASE_STRIP = YES; 435 | ENABLE_NS_ASSERTIONS = NO; 436 | GCC_C_LANGUAGE_STANDARD = gnu99; 437 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 438 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 439 | GCC_WARN_UNDECLARED_SELECTOR = YES; 440 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 441 | GCC_WARN_UNUSED_FUNCTION = YES; 442 | GCC_WARN_UNUSED_VARIABLE = YES; 443 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 444 | SDKROOT = iphoneos; 445 | VALIDATE_PRODUCT = YES; 446 | }; 447 | name = Release; 448 | }; 449 | 84F0C33618962C3F00870008 /* Debug */ = { 450 | isa = XCBuildConfiguration; 451 | buildSettings = { 452 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 453 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 454 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 455 | GCC_PREFIX_HEADER = "GHContextMenu/GHContextMenu-Prefix.pch"; 456 | INFOPLIST_FILE = "GHContextMenu/GHContextMenu-Info.plist"; 457 | PRODUCT_NAME = "$(TARGET_NAME)"; 458 | WRAPPER_EXTENSION = app; 459 | }; 460 | name = Debug; 461 | }; 462 | 84F0C33718962C3F00870008 /* Release */ = { 463 | isa = XCBuildConfiguration; 464 | buildSettings = { 465 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 466 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 467 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 468 | GCC_PREFIX_HEADER = "GHContextMenu/GHContextMenu-Prefix.pch"; 469 | INFOPLIST_FILE = "GHContextMenu/GHContextMenu-Info.plist"; 470 | PRODUCT_NAME = "$(TARGET_NAME)"; 471 | WRAPPER_EXTENSION = app; 472 | }; 473 | name = Release; 474 | }; 475 | 84F0C33918962C3F00870008 /* Debug */ = { 476 | isa = XCBuildConfiguration; 477 | buildSettings = { 478 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 479 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/GHContextMenu.app/GHContextMenu"; 480 | FRAMEWORK_SEARCH_PATHS = ( 481 | "$(SDKROOT)/Developer/Library/Frameworks", 482 | "$(inherited)", 483 | "$(DEVELOPER_FRAMEWORKS_DIR)", 484 | ); 485 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 486 | GCC_PREFIX_HEADER = "GHContextMenu/GHContextMenu-Prefix.pch"; 487 | GCC_PREPROCESSOR_DEFINITIONS = ( 488 | "DEBUG=1", 489 | "$(inherited)", 490 | ); 491 | INFOPLIST_FILE = "GHContextMenuTests/GHContextMenuTests-Info.plist"; 492 | PRODUCT_NAME = "$(TARGET_NAME)"; 493 | TEST_HOST = "$(BUNDLE_LOADER)"; 494 | WRAPPER_EXTENSION = xctest; 495 | }; 496 | name = Debug; 497 | }; 498 | 84F0C33A18962C3F00870008 /* Release */ = { 499 | isa = XCBuildConfiguration; 500 | buildSettings = { 501 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 502 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/GHContextMenu.app/GHContextMenu"; 503 | FRAMEWORK_SEARCH_PATHS = ( 504 | "$(SDKROOT)/Developer/Library/Frameworks", 505 | "$(inherited)", 506 | "$(DEVELOPER_FRAMEWORKS_DIR)", 507 | ); 508 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 509 | GCC_PREFIX_HEADER = "GHContextMenu/GHContextMenu-Prefix.pch"; 510 | INFOPLIST_FILE = "GHContextMenuTests/GHContextMenuTests-Info.plist"; 511 | PRODUCT_NAME = "$(TARGET_NAME)"; 512 | TEST_HOST = "$(BUNDLE_LOADER)"; 513 | WRAPPER_EXTENSION = xctest; 514 | }; 515 | name = Release; 516 | }; 517 | /* End XCBuildConfiguration section */ 518 | 519 | /* Begin XCConfigurationList section */ 520 | 84F0C2FE18962C3F00870008 /* Build configuration list for PBXProject "GHContextMenuDemo" */ = { 521 | isa = XCConfigurationList; 522 | buildConfigurations = ( 523 | 84F0C33318962C3F00870008 /* Debug */, 524 | 84F0C33418962C3F00870008 /* Release */, 525 | ); 526 | defaultConfigurationIsVisible = 0; 527 | defaultConfigurationName = Release; 528 | }; 529 | 84F0C33518962C3F00870008 /* Build configuration list for PBXNativeTarget "GHContextMenu" */ = { 530 | isa = XCConfigurationList; 531 | buildConfigurations = ( 532 | 84F0C33618962C3F00870008 /* Debug */, 533 | 84F0C33718962C3F00870008 /* Release */, 534 | ); 535 | defaultConfigurationIsVisible = 0; 536 | defaultConfigurationName = Release; 537 | }; 538 | 84F0C33818962C3F00870008 /* Build configuration list for PBXNativeTarget "GHContextMenuTests" */ = { 539 | isa = XCConfigurationList; 540 | buildConfigurations = ( 541 | 84F0C33918962C3F00870008 /* Debug */, 542 | 84F0C33A18962C3F00870008 /* Release */, 543 | ); 544 | defaultConfigurationIsVisible = 0; 545 | defaultConfigurationName = Release; 546 | }; 547 | /* End XCConfigurationList section */ 548 | }; 549 | rootObject = 84F0C2FB18962C3F00870008 /* Project object */; 550 | } 551 | --------------------------------------------------------------------------------