├── .gitignore ├── LICENSE ├── PininterestLikeMenu ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── Main_iPad.storyboard │ └── Main_iPhone.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── PininterestLikeMenu │ ├── PinterestLikeMenu.h │ ├── PinterestLikeMenu.m │ ├── PinterestLikeMenuItem.h │ └── PinterestLikeMenuItem.m ├── PinterestLikeMenu-Info.plist ├── PinterestLikeMenu-Prefix.pch ├── ViewController.h ├── ViewController.m ├── en.lproj │ └── InfoPlist.strings ├── images │ ├── center-highlighted.png │ ├── center-highlighted@2x.png │ ├── center.png │ └── center@2x.png └── main.m ├── PinterestLikeMenu.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | */build/* 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | profile 14 | *.moved-aside 15 | DerivedData 16 | .idea/ 17 | *.hmap 18 | *.xccheckout 19 | 20 | #CocoaPods 21 | Pods 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 itouch2 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /PininterestLikeMenu/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // PininterestLikeMenu 4 | // 5 | // Created by Tu You on 12/21/13. 6 | // Copyright (c) 2013 Tu You. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PininterestLikeMenu/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // PininterestLikeMenu 4 | // 5 | // Created by Tu You on 12/21/13. 6 | // Copyright (c) 2013 Tu You. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @implementation AppDelegate 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 | -------------------------------------------------------------------------------- /PininterestLikeMenu/Base.lproj/Main_iPad.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /PininterestLikeMenu/Base.lproj/Main_iPhone.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /PininterestLikeMenu/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 | "idiom" : "ipad", 20 | "size" : "29x29", 21 | "scale" : "1x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "size" : "29x29", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "ipad", 30 | "size" : "40x40", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "40x40", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "76x76", 41 | "scale" : "1x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "76x76", 46 | "scale" : "2x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } -------------------------------------------------------------------------------- /PininterestLikeMenu/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 | "orientation" : "portrait", 20 | "idiom" : "ipad", 21 | "extent" : "full-screen", 22 | "minimum-system-version" : "7.0", 23 | "scale" : "1x" 24 | }, 25 | { 26 | "orientation" : "landscape", 27 | "idiom" : "ipad", 28 | "extent" : "full-screen", 29 | "minimum-system-version" : "7.0", 30 | "scale" : "1x" 31 | }, 32 | { 33 | "orientation" : "portrait", 34 | "idiom" : "ipad", 35 | "extent" : "full-screen", 36 | "minimum-system-version" : "7.0", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "orientation" : "landscape", 41 | "idiom" : "ipad", 42 | "extent" : "full-screen", 43 | "minimum-system-version" : "7.0", 44 | "scale" : "2x" 45 | } 46 | ], 47 | "info" : { 48 | "version" : 1, 49 | "author" : "xcode" 50 | } 51 | } -------------------------------------------------------------------------------- /PininterestLikeMenu/PininterestLikeMenu/PinterestLikeMenu.h: -------------------------------------------------------------------------------- 1 | // 2 | // PinterestLikeMenu.h 3 | // PinterestLikeMenu 4 | // 5 | // Created by Tu You on 12/21/13. 6 | // Copyright (c) 2013 Tu You. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PinterestLikeMenuItem.h" 11 | 12 | @interface PinterestLikeMenu : UIView 13 | 14 | @property (nonatomic, assign) CGPoint startPoint; 15 | 16 | - (id)initWithSubmenus:(NSArray *)submenus; 17 | - (id)initWithSubmenus:(NSArray *)submenus startPoint:(CGPoint)point; 18 | 19 | - (void)show; 20 | - (void)updataLocation:(CGPoint)location; 21 | - (void)finished; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /PininterestLikeMenu/PininterestLikeMenu/PinterestLikeMenu.m: -------------------------------------------------------------------------------- 1 | // 2 | // PininterestLikeMenu.m 3 | // PininterestLikeMenu 4 | // 5 | // Created by Tu You on 12/21/13. 6 | // Copyright (c) 2013 Tu You. All rights reserved. 7 | // 8 | 9 | #import "PinterestLikeMenu.h" 10 | 11 | #define kMaxAngle M_PI_2 12 | #define kMaxLength (95) 13 | #define kLength (75) 14 | #define kBounceLength (18) 15 | #define kPulseLength (60) 16 | 17 | static CGFloat distanceBetweenXAndY(CGPoint pointX, CGPoint pointY) 18 | { 19 | CGFloat distance = 0; 20 | CGFloat offsetX = pointX.x - pointY.x; 21 | CGFloat offsetY = pointX.y - pointY.y; 22 | distance = sqrtf(pow(offsetX, 2) + pow(offsetY, 2)); 23 | return distance; 24 | } 25 | 26 | @interface PinterestLikeMenu () 27 | 28 | @property (nonatomic, strong) NSArray *submenus; 29 | @property (nonatomic, strong) UIImageView *startImageView; 30 | 31 | @end 32 | 33 | @implementation PinterestLikeMenu 34 | 35 | - (id)initWithSubmenus:(NSArray *)submenus 36 | { 37 | return [self initWithSubmenus:submenus startPoint:CGPointZero]; 38 | } 39 | 40 | - (id)initWithSubmenus:(NSArray *)submenus startPoint:(CGPoint)point 41 | { 42 | if (self = [super init]) 43 | { 44 | self.frame = [UIApplication sharedApplication].keyWindow.frame; 45 | 46 | self.backgroundColor = [UIColor colorWithWhite:0.2 alpha:0.5]; 47 | 48 | self.submenus = submenus; 49 | 50 | self.startImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kMenuItemLength, kMenuItemLength)]; 51 | self.startImageView.image = [UIImage imageNamed:@"center"]; 52 | 53 | self.startPoint = point; 54 | 55 | for (int i = 0; i < self.submenus.count; i++) 56 | { 57 | ((UIView *)(self.submenus[i])).center = self.startPoint; 58 | 59 | [self addSubview:self.submenus[i]]; 60 | } 61 | 62 | [self addSubview:self.startImageView]; 63 | 64 | } 65 | return self; 66 | } 67 | 68 | - (void)setStartPoint:(CGPoint)point 69 | { 70 | point.x = point.x < kMenuItemLength / 2 ? kMenuItemLength / 2 : point.x; 71 | point.x = point.x > (320 - kMenuItemLength / 2) ? (320 - kMenuItemLength / 2) : point.x; 72 | 73 | _startPoint = point; 74 | 75 | _startImageView.center = point; 76 | 77 | for (int i = 0; i < self.submenus.count; i++) 78 | { 79 | ((UIView *)(self.submenus[i])).center = self.startPoint; 80 | } 81 | } 82 | 83 | - (void)show 84 | { 85 | UIWindow *window = [UIApplication sharedApplication].keyWindow; 86 | [window addSubview:self]; 87 | 88 | [self appear]; 89 | } 90 | 91 | - (void)updataLocation:(CGPoint)touchedPoint 92 | { 93 | int closestIndex = 0; 94 | float minDistance = CGFLOAT_MAX; 95 | 96 | // find the cloest menu item 97 | for (int i = 0; i < self.submenus.count; i++) 98 | { 99 | CGPoint floatingPoint = [self floatingPointWithIndex:i]; 100 | 101 | CGFloat distance = distanceBetweenXAndY(touchedPoint, floatingPoint); 102 | 103 | if (distance < minDistance) 104 | { 105 | minDistance = distance; 106 | closestIndex = i; 107 | } 108 | } 109 | 110 | for (int i = 0; i < self.submenus.count; i++) 111 | { 112 | PinterestLikeMenuItem *menuItem = self.submenus[i]; 113 | 114 | // the cloest point 115 | if (i == closestIndex) 116 | { 117 | CGPoint floatingPoint = [self floatingPointWithIndex:i]; 118 | CGFloat currentDistance = distanceBetweenXAndY(touchedPoint, floatingPoint); 119 | currentDistance = currentDistance > kMaxLength ? kMaxLength : currentDistance; 120 | float step = (currentDistance / kMaxLength) * (kMaxLength - kLength); 121 | 122 | [UIView animateWithDuration:0.1 animations:^{ 123 | [self moveWithIndex:i offsetOfFloatingPoint:step]; 124 | }]; 125 | 126 | CGFloat distance = distanceBetweenXAndY(touchedPoint, floatingPoint); 127 | 128 | // if close enough, highlight the point 129 | if (distance < kPulseLength) 130 | { 131 | menuItem.selected = YES; 132 | } 133 | else 134 | { 135 | menuItem.selected = NO; 136 | } 137 | } 138 | else 139 | { 140 | // back to init state 141 | [UIView animateWithDuration:0.20 animations:^{ 142 | [self setThePostion:i]; 143 | } completion:^(BOOL finished) { 144 | menuItem.selected = NO; 145 | }]; 146 | } 147 | } 148 | 149 | } 150 | 151 | - (void)finished 152 | { 153 | for (int i = 0; i < self.submenus.count; i++) 154 | { 155 | PinterestLikeMenuItem *menuItem = self.submenus[i]; 156 | if (menuItem.selected) 157 | { 158 | if (menuItem.selectedBlock) 159 | { 160 | menuItem.selectedBlock(); 161 | } 162 | break; 163 | } 164 | } 165 | [self disappear]; 166 | } 167 | 168 | - (void)moveWithIndex:(int)index offsetOfFloatingPoint:(float)offset 169 | { 170 | UIView *menuItem = (UIView *)self.submenus[index]; 171 | CGPoint floating = [self floatingPointWithIndex:index]; 172 | float radian = [self radianWithIndex:index]; 173 | radian = radian - M_PI; 174 | float x = floating.x + offset * cos(radian); 175 | float y = floating.y + offset * sin(radian); 176 | menuItem.center = CGPointMake(x, y); 177 | } 178 | 179 | - (void)setThePostion:(int)index 180 | { 181 | float radian = [self radianWithIndex:index]; 182 | float x = kLength * cos(radian); 183 | float y = kLength * sin(radian); 184 | UIView *view = self.submenus[index]; 185 | view.center = CGPointMake(_startPoint.x + x, _startPoint.y + y); 186 | } 187 | 188 | - (CGPoint)floatingPointWithIndex:(int)index 189 | { 190 | float radian = [self radianWithIndex:index]; 191 | float x = kMaxLength * cos(radian); 192 | float y = kMaxLength * sin(radian); 193 | CGPoint point = CGPointMake(_startPoint.x + x, _startPoint.y + y); 194 | return point; 195 | } 196 | 197 | - (float)radianWithIndex:(int)index 198 | { 199 | NSUInteger count = self.submenus.count; 200 | 201 | // from 3/2 -> 2/2 0 -> 320 (20 -> 300) 202 | 203 | float startRadian = M_PI_2 * 3 - ((self.startPoint.x - 20) / (320 - 20 * 2)) * M_PI_2; 204 | float step = kMaxAngle / (count - 1); 205 | float radian = startRadian + index * step; 206 | 207 | return radian; 208 | } 209 | 210 | - (void)appear 211 | { 212 | for (int i = 0; i < self.submenus.count; i++) 213 | { 214 | [self pulseTheMenuAtIndex:i]; 215 | } 216 | } 217 | 218 | - (void)disappear 219 | { 220 | [UIView animateWithDuration:0.2 animations:^{ 221 | self.alpha = 0; 222 | } completion:^(BOOL finished) { 223 | [self removeFromSuperview]; 224 | }]; 225 | } 226 | 227 | - (void)pulseTheMenuAtIndex:(int)index 228 | { 229 | UIView *view = (UIView *)self.submenus[index]; 230 | [UIView animateWithDuration:0.25 231 | delay:0 232 | options:UIViewAnimationOptionCurveEaseIn 233 | animations:^{ 234 | 235 | float radian = [self radianWithIndex:index]; 236 | float y = (kLength + kBounceLength) * sin(radian); 237 | float x = (kLength + kBounceLength) * cos(radian); 238 | view.center = CGPointMake(_startPoint.x + x, _startPoint.y + y); 239 | 240 | } completion:^(BOOL finished) { 241 | 242 | [UIView animateWithDuration:0.15 243 | animations:^{ 244 | 245 | float radian = [self radianWithIndex:index]; 246 | float y = kLength * sin(radian); 247 | float x = kLength * cos(radian); 248 | view.center = CGPointMake(_startPoint.x + x, _startPoint.y + y); 249 | 250 | } completion:^(BOOL finished) { 251 | 252 | }]; 253 | }]; 254 | } 255 | 256 | @end 257 | -------------------------------------------------------------------------------- /PininterestLikeMenu/PininterestLikeMenu/PinterestLikeMenuItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // PinterestLikeMenuItem.h 3 | // PinterestLikeMenu 4 | // 5 | // Created by Tu You on 12/21/13. 6 | // Copyright (c) 2013 Tu You. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #define kMenuItemLength (40) 12 | 13 | typedef void(^SelectedBlock)(void); 14 | 15 | @interface PinterestLikeMenuItem : UIView 16 | 17 | @property (nonatomic, strong) UIImage *image; 18 | @property (nonatomic, strong) UIImage *selectedImage; 19 | @property (nonatomic, strong) SelectedBlock selectedBlock; 20 | @property (nonatomic, strong) UILabel *label; 21 | @property (nonatomic, assign) BOOL selected; 22 | @property (nonatomic, assign) float distance; 23 | 24 | - (id)initWithImage:(UIImage *)image 25 | selctedImage:(UIImage *)selectedImage 26 | selectedBlock:(SelectedBlock)selectedBlock; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /PininterestLikeMenu/PininterestLikeMenu/PinterestLikeMenuItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // PininterestLikeMenuItem.m 3 | // PininterestLikeMenu 4 | // 5 | // Created by Tu You on 12/21/13. 6 | // Copyright (c) 2013 Tu You. All rights reserved. 7 | // 8 | 9 | #import "PinterestLikeMenuItem.h" 10 | 11 | 12 | 13 | @interface PinterestLikeMenuItem () 14 | 15 | @property (nonatomic, strong) UIImageView *imageView; 16 | 17 | @end 18 | 19 | 20 | @implementation PinterestLikeMenuItem 21 | 22 | - (id)initWithFrame:(CGRect)frame 23 | { 24 | self = [super initWithFrame:frame]; 25 | if (self) { 26 | // Initialization code 27 | } 28 | return self; 29 | } 30 | 31 | - (id)initWithImage:(UIImage *)image selctedImage:(UIImage *)selectedImage selectedBlock:(SelectedBlock)selectedBlock 32 | { 33 | if (self = [super init]) 34 | { 35 | self.bounds = CGRectMake(0, 0, kMenuItemLength, kMenuItemLength); 36 | 37 | self.imageView = [[UIImageView alloc] initWithImage:image]; 38 | self.imageView.frame = self.bounds; 39 | self.imageView.image = image; 40 | self.imageView.highlightedImage = selectedImage; 41 | [self addSubview:self.imageView]; 42 | 43 | self.selectedBlock = selectedBlock; 44 | 45 | } 46 | return self; 47 | } 48 | 49 | - (void)setSelected:(BOOL)selected 50 | { 51 | _selected = selected; 52 | 53 | self.imageView.highlighted = selected; 54 | } 55 | 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /PininterestLikeMenu/PinterestLikeMenu-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | COM.TUYOU.${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_iPhone 29 | UIMainStoryboardFile~ipad 30 | Main_iPad 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | UISupportedInterfaceOrientations~ipad 42 | 43 | UIInterfaceOrientationPortrait 44 | UIInterfaceOrientationPortraitUpsideDown 45 | UIInterfaceOrientationLandscapeLeft 46 | UIInterfaceOrientationLandscapeRight 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /PininterestLikeMenu/PinterestLikeMenu-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 | -------------------------------------------------------------------------------- /PininterestLikeMenu/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // PinterestLikeMenu 4 | // 5 | // Created by Tu You on 12/21/13. 6 | // Copyright (c) 2013 Tu You. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PininterestLikeMenu/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // PinterestLikeMenu 4 | // 5 | // Created by Tu You on 12/21/13. 6 | // Copyright (c) 2013 Tu You. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "PinterestLikeMenu.h" 11 | 12 | @interface ViewController () 13 | 14 | @property (nonatomic, strong) PinterestLikeMenu *menu; 15 | 16 | @end 17 | 18 | @implementation ViewController 19 | 20 | - (void)viewDidLoad 21 | { 22 | [super viewDidLoad]; 23 | // Do any additional setup after loading the view, typically from a nib. 24 | 25 | UILongPressGestureRecognizer *gesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(popPinterestMenu:)]; 26 | gesture.delegate = self; 27 | 28 | [self.view addGestureRecognizer:gesture]; 29 | } 30 | 31 | - (PinterestLikeMenu *)menu 32 | { 33 | if (!_menu) 34 | { 35 | PinterestLikeMenuItem *item0 = [[PinterestLikeMenuItem alloc] initWithImage:[UIImage imageNamed:@"center"] 36 | selctedImage:[UIImage imageNamed:@"center-highlighted"] 37 | selectedBlock:^(void) { 38 | NSLog(@"item 0 selected"); 39 | }]; 40 | PinterestLikeMenuItem *item1 = [[PinterestLikeMenuItem alloc] initWithImage:[UIImage imageNamed:@"center"] 41 | selctedImage:[UIImage imageNamed:@"center-highlighted"] 42 | selectedBlock:^(void) { 43 | NSLog(@"item 1 selected"); 44 | }]; 45 | PinterestLikeMenuItem *item2 = [[PinterestLikeMenuItem alloc] initWithImage:[UIImage imageNamed:@"center"] 46 | selctedImage:[UIImage imageNamed:@"center-highlighted"] 47 | selectedBlock:^(void) { 48 | NSLog(@"item 2 selcted"); 49 | }]; 50 | NSArray *submenus = @[item0, item1, item2]; 51 | 52 | self.menu = [[PinterestLikeMenu alloc] initWithSubmenus:submenus]; 53 | 54 | } 55 | return _menu; 56 | } 57 | 58 | - (void)popPinterestMenu:(UIGestureRecognizer *)gesture 59 | { 60 | CGPoint location = [gesture locationInView:self.view.window]; 61 | 62 | if (gesture.state == UIGestureRecognizerStateBegan) 63 | { 64 | // set the start point where the menu showing up 65 | self.menu.startPoint = location; 66 | [self.menu show]; 67 | } 68 | else if (gesture.state == UIGestureRecognizerStateChanged) 69 | { 70 | [self.menu updataLocation:location]; 71 | } 72 | else 73 | { 74 | [self.menu finished]; 75 | self.menu = nil; 76 | } 77 | } 78 | 79 | - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer 80 | { 81 | return NO; 82 | } 83 | 84 | - (void)didReceiveMemoryWarning 85 | { 86 | [super didReceiveMemoryWarning]; 87 | // Dispose of any resources that can be recreated. 88 | } 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /PininterestLikeMenu/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /PininterestLikeMenu/images/center-highlighted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itouch2/PinterestLikeMenu/772d2e3caf683c3d3dc0b72a835a47e64fee5b33/PininterestLikeMenu/images/center-highlighted.png -------------------------------------------------------------------------------- /PininterestLikeMenu/images/center-highlighted@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itouch2/PinterestLikeMenu/772d2e3caf683c3d3dc0b72a835a47e64fee5b33/PininterestLikeMenu/images/center-highlighted@2x.png -------------------------------------------------------------------------------- /PininterestLikeMenu/images/center.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itouch2/PinterestLikeMenu/772d2e3caf683c3d3dc0b72a835a47e64fee5b33/PininterestLikeMenu/images/center.png -------------------------------------------------------------------------------- /PininterestLikeMenu/images/center@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itouch2/PinterestLikeMenu/772d2e3caf683c3d3dc0b72a835a47e64fee5b33/PininterestLikeMenu/images/center@2x.png -------------------------------------------------------------------------------- /PininterestLikeMenu/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // PininterestLikeMenu 4 | // 5 | // Created by Tu You on 12/21/13. 6 | // Copyright (c) 2013 Tu You. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /PinterestLikeMenu.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CB29B3DD18AA2F2100EAE9AC /* PinterestLikeMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = CB29B3DA18AA2F2100EAE9AC /* PinterestLikeMenu.m */; }; 11 | CB29B3DE18AA2F2100EAE9AC /* PinterestLikeMenuItem.m in Sources */ = {isa = PBXBuildFile; fileRef = CB29B3DC18AA2F2100EAE9AC /* PinterestLikeMenuItem.m */; }; 12 | CB8DCCC61865BBBD006A75E9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8DCCC51865BBBD006A75E9 /* Foundation.framework */; }; 13 | CB8DCCC81865BBBD006A75E9 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8DCCC71865BBBD006A75E9 /* CoreGraphics.framework */; }; 14 | CB8DCCCA1865BBBD006A75E9 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8DCCC91865BBBD006A75E9 /* UIKit.framework */; }; 15 | CB8DCCD01865BBBD006A75E9 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = CB8DCCCE1865BBBD006A75E9 /* InfoPlist.strings */; }; 16 | CB8DCCD21865BBBD006A75E9 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = CB8DCCD11865BBBD006A75E9 /* main.m */; }; 17 | CB8DCCD61865BBBD006A75E9 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = CB8DCCD51865BBBD006A75E9 /* AppDelegate.m */; }; 18 | CB8DCCD91865BBBD006A75E9 /* Main_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CB8DCCD71865BBBD006A75E9 /* Main_iPhone.storyboard */; }; 19 | CB8DCCDC1865BBBD006A75E9 /* Main_iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CB8DCCDA1865BBBD006A75E9 /* Main_iPad.storyboard */; }; 20 | CB8DCCDF1865BBBD006A75E9 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = CB8DCCDE1865BBBD006A75E9 /* ViewController.m */; }; 21 | CB8DCCE11865BBBD006A75E9 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CB8DCCE01865BBBD006A75E9 /* Images.xcassets */; }; 22 | CB8DCCE81865BBBD006A75E9 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8DCCE71865BBBD006A75E9 /* XCTest.framework */; }; 23 | CB8DCCE91865BBBD006A75E9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8DCCC51865BBBD006A75E9 /* Foundation.framework */; }; 24 | CB8DCCEA1865BBBD006A75E9 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB8DCCC91865BBBD006A75E9 /* UIKit.framework */; }; 25 | CBCD9B0C1869E0F2008F26DA /* center-highlighted.png in Resources */ = {isa = PBXBuildFile; fileRef = CBCD9B0A1869E0F2008F26DA /* center-highlighted.png */; }; 26 | CBCD9B0D1869E0F2008F26DA /* center-highlighted@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = CBCD9B0B1869E0F2008F26DA /* center-highlighted@2x.png */; }; 27 | CBE22499186875DB0018EF3D /* center.png in Resources */ = {isa = PBXBuildFile; fileRef = CBE22497186875DB0018EF3D /* center.png */; }; 28 | CBE2249A186875DB0018EF3D /* center@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = CBE22498186875DB0018EF3D /* center@2x.png */; }; 29 | /* End PBXBuildFile section */ 30 | 31 | /* Begin PBXContainerItemProxy section */ 32 | CB8DCCEB1865BBBD006A75E9 /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = CB8DCCBA1865BBBD006A75E9 /* Project object */; 35 | proxyType = 1; 36 | remoteGlobalIDString = CB8DCCC11865BBBD006A75E9; 37 | remoteInfo = PininterestLikeMenu; 38 | }; 39 | /* End PBXContainerItemProxy section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | CB29B3D918AA2F2100EAE9AC /* PinterestLikeMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PinterestLikeMenu.h; sourceTree = ""; }; 43 | CB29B3DA18AA2F2100EAE9AC /* PinterestLikeMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PinterestLikeMenu.m; sourceTree = ""; }; 44 | CB29B3DB18AA2F2100EAE9AC /* PinterestLikeMenuItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PinterestLikeMenuItem.h; sourceTree = ""; }; 45 | CB29B3DC18AA2F2100EAE9AC /* PinterestLikeMenuItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PinterestLikeMenuItem.m; sourceTree = ""; }; 46 | CB8DCCC21865BBBD006A75E9 /* PinterestLikeMenu.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PinterestLikeMenu.app; sourceTree = BUILT_PRODUCTS_DIR; }; 47 | CB8DCCC51865BBBD006A75E9 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 48 | CB8DCCC71865BBBD006A75E9 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 49 | CB8DCCC91865BBBD006A75E9 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 50 | CB8DCCCD1865BBBD006A75E9 /* PinterestLikeMenu-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "PinterestLikeMenu-Info.plist"; sourceTree = ""; }; 51 | CB8DCCCF1865BBBD006A75E9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 52 | CB8DCCD11865BBBD006A75E9 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 53 | CB8DCCD31865BBBD006A75E9 /* PinterestLikeMenu-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PinterestLikeMenu-Prefix.pch"; sourceTree = ""; }; 54 | CB8DCCD41865BBBD006A75E9 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 55 | CB8DCCD51865BBBD006A75E9 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 56 | CB8DCCD81865BBBD006A75E9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main_iPhone.storyboard; sourceTree = ""; }; 57 | CB8DCCDB1865BBBD006A75E9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main_iPad.storyboard; sourceTree = ""; }; 58 | CB8DCCDD1865BBBD006A75E9 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 59 | CB8DCCDE1865BBBD006A75E9 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 60 | CB8DCCE01865BBBD006A75E9 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 61 | CB8DCCE61865BBBD006A75E9 /* PinterestLikeMenuTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PinterestLikeMenuTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 62 | CB8DCCE71865BBBD006A75E9 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 63 | CBCD9B0A1869E0F2008F26DA /* center-highlighted.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "center-highlighted.png"; sourceTree = ""; }; 64 | CBCD9B0B1869E0F2008F26DA /* center-highlighted@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "center-highlighted@2x.png"; sourceTree = ""; }; 65 | CBE22497186875DB0018EF3D /* center.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = center.png; sourceTree = ""; }; 66 | CBE22498186875DB0018EF3D /* center@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "center@2x.png"; sourceTree = ""; }; 67 | /* End PBXFileReference section */ 68 | 69 | /* Begin PBXFrameworksBuildPhase section */ 70 | CB8DCCBF1865BBBD006A75E9 /* Frameworks */ = { 71 | isa = PBXFrameworksBuildPhase; 72 | buildActionMask = 2147483647; 73 | files = ( 74 | CB8DCCC81865BBBD006A75E9 /* CoreGraphics.framework in Frameworks */, 75 | CB8DCCCA1865BBBD006A75E9 /* UIKit.framework in Frameworks */, 76 | CB8DCCC61865BBBD006A75E9 /* Foundation.framework in Frameworks */, 77 | ); 78 | runOnlyForDeploymentPostprocessing = 0; 79 | }; 80 | CB8DCCE31865BBBD006A75E9 /* Frameworks */ = { 81 | isa = PBXFrameworksBuildPhase; 82 | buildActionMask = 2147483647; 83 | files = ( 84 | CB8DCCE81865BBBD006A75E9 /* XCTest.framework in Frameworks */, 85 | CB8DCCEA1865BBBD006A75E9 /* UIKit.framework in Frameworks */, 86 | CB8DCCE91865BBBD006A75E9 /* Foundation.framework in Frameworks */, 87 | ); 88 | runOnlyForDeploymentPostprocessing = 0; 89 | }; 90 | /* End PBXFrameworksBuildPhase section */ 91 | 92 | /* Begin PBXGroup section */ 93 | CB29B3D818AA2F2100EAE9AC /* PininterestLikeMenu */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | CB29B3D918AA2F2100EAE9AC /* PinterestLikeMenu.h */, 97 | CB29B3DA18AA2F2100EAE9AC /* PinterestLikeMenu.m */, 98 | CB29B3DB18AA2F2100EAE9AC /* PinterestLikeMenuItem.h */, 99 | CB29B3DC18AA2F2100EAE9AC /* PinterestLikeMenuItem.m */, 100 | ); 101 | path = PininterestLikeMenu; 102 | sourceTree = ""; 103 | }; 104 | CB8DCCB91865BBBD006A75E9 = { 105 | isa = PBXGroup; 106 | children = ( 107 | CB8DCCCB1865BBBD006A75E9 /* PininterestLikeMenu */, 108 | CB8DCCC41865BBBD006A75E9 /* Frameworks */, 109 | CB8DCCC31865BBBD006A75E9 /* Products */, 110 | ); 111 | sourceTree = ""; 112 | }; 113 | CB8DCCC31865BBBD006A75E9 /* Products */ = { 114 | isa = PBXGroup; 115 | children = ( 116 | CB8DCCC21865BBBD006A75E9 /* PinterestLikeMenu.app */, 117 | CB8DCCE61865BBBD006A75E9 /* PinterestLikeMenuTests.xctest */, 118 | ); 119 | name = Products; 120 | sourceTree = ""; 121 | }; 122 | CB8DCCC41865BBBD006A75E9 /* Frameworks */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | CB8DCCC51865BBBD006A75E9 /* Foundation.framework */, 126 | CB8DCCC71865BBBD006A75E9 /* CoreGraphics.framework */, 127 | CB8DCCC91865BBBD006A75E9 /* UIKit.framework */, 128 | CB8DCCE71865BBBD006A75E9 /* XCTest.framework */, 129 | ); 130 | name = Frameworks; 131 | sourceTree = ""; 132 | }; 133 | CB8DCCCB1865BBBD006A75E9 /* PininterestLikeMenu */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | CB8DCCD41865BBBD006A75E9 /* AppDelegate.h */, 137 | CB8DCCD51865BBBD006A75E9 /* AppDelegate.m */, 138 | CB8DCCD71865BBBD006A75E9 /* Main_iPhone.storyboard */, 139 | CB8DCCDA1865BBBD006A75E9 /* Main_iPad.storyboard */, 140 | CB8DCCDD1865BBBD006A75E9 /* ViewController.h */, 141 | CB8DCCDE1865BBBD006A75E9 /* ViewController.m */, 142 | CB29B3D818AA2F2100EAE9AC /* PininterestLikeMenu */, 143 | CBE22496186875DB0018EF3D /* images */, 144 | CB8DCCE01865BBBD006A75E9 /* Images.xcassets */, 145 | CB8DCCCC1865BBBD006A75E9 /* Supporting Files */, 146 | ); 147 | path = PininterestLikeMenu; 148 | sourceTree = ""; 149 | }; 150 | CB8DCCCC1865BBBD006A75E9 /* Supporting Files */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | CB8DCCCD1865BBBD006A75E9 /* PinterestLikeMenu-Info.plist */, 154 | CB8DCCCE1865BBBD006A75E9 /* InfoPlist.strings */, 155 | CB8DCCD11865BBBD006A75E9 /* main.m */, 156 | CB8DCCD31865BBBD006A75E9 /* PinterestLikeMenu-Prefix.pch */, 157 | ); 158 | name = "Supporting Files"; 159 | sourceTree = ""; 160 | }; 161 | CBE22496186875DB0018EF3D /* images */ = { 162 | isa = PBXGroup; 163 | children = ( 164 | CBE22497186875DB0018EF3D /* center.png */, 165 | CBE22498186875DB0018EF3D /* center@2x.png */, 166 | CBCD9B0A1869E0F2008F26DA /* center-highlighted.png */, 167 | CBCD9B0B1869E0F2008F26DA /* center-highlighted@2x.png */, 168 | ); 169 | path = images; 170 | sourceTree = ""; 171 | }; 172 | /* End PBXGroup section */ 173 | 174 | /* Begin PBXNativeTarget section */ 175 | CB8DCCC11865BBBD006A75E9 /* PinterestLikeMenu */ = { 176 | isa = PBXNativeTarget; 177 | buildConfigurationList = CB8DCCF71865BBBD006A75E9 /* Build configuration list for PBXNativeTarget "PinterestLikeMenu" */; 178 | buildPhases = ( 179 | CB8DCCBE1865BBBD006A75E9 /* Sources */, 180 | CB8DCCBF1865BBBD006A75E9 /* Frameworks */, 181 | CB8DCCC01865BBBD006A75E9 /* Resources */, 182 | ); 183 | buildRules = ( 184 | ); 185 | dependencies = ( 186 | ); 187 | name = PinterestLikeMenu; 188 | productName = PininterestLikeMenu; 189 | productReference = CB8DCCC21865BBBD006A75E9 /* PinterestLikeMenu.app */; 190 | productType = "com.apple.product-type.application"; 191 | }; 192 | CB8DCCE51865BBBD006A75E9 /* PinterestLikeMenuTests */ = { 193 | isa = PBXNativeTarget; 194 | buildConfigurationList = CB8DCCFA1865BBBD006A75E9 /* Build configuration list for PBXNativeTarget "PinterestLikeMenuTests" */; 195 | buildPhases = ( 196 | CB8DCCE21865BBBD006A75E9 /* Sources */, 197 | CB8DCCE31865BBBD006A75E9 /* Frameworks */, 198 | CB8DCCE41865BBBD006A75E9 /* Resources */, 199 | ); 200 | buildRules = ( 201 | ); 202 | dependencies = ( 203 | CB8DCCEC1865BBBD006A75E9 /* PBXTargetDependency */, 204 | ); 205 | name = PinterestLikeMenuTests; 206 | productName = PininterestLikeMenuTests; 207 | productReference = CB8DCCE61865BBBD006A75E9 /* PinterestLikeMenuTests.xctest */; 208 | productType = "com.apple.product-type.bundle.unit-test"; 209 | }; 210 | /* End PBXNativeTarget section */ 211 | 212 | /* Begin PBXProject section */ 213 | CB8DCCBA1865BBBD006A75E9 /* Project object */ = { 214 | isa = PBXProject; 215 | attributes = { 216 | LastUpgradeCheck = 0500; 217 | ORGANIZATIONNAME = "Tu You"; 218 | TargetAttributes = { 219 | CB8DCCE51865BBBD006A75E9 = { 220 | TestTargetID = CB8DCCC11865BBBD006A75E9; 221 | }; 222 | }; 223 | }; 224 | buildConfigurationList = CB8DCCBD1865BBBD006A75E9 /* Build configuration list for PBXProject "PinterestLikeMenu" */; 225 | compatibilityVersion = "Xcode 3.2"; 226 | developmentRegion = English; 227 | hasScannedForEncodings = 0; 228 | knownRegions = ( 229 | en, 230 | Base, 231 | ); 232 | mainGroup = CB8DCCB91865BBBD006A75E9; 233 | productRefGroup = CB8DCCC31865BBBD006A75E9 /* Products */; 234 | projectDirPath = ""; 235 | projectRoot = ""; 236 | targets = ( 237 | CB8DCCC11865BBBD006A75E9 /* PinterestLikeMenu */, 238 | CB8DCCE51865BBBD006A75E9 /* PinterestLikeMenuTests */, 239 | ); 240 | }; 241 | /* End PBXProject section */ 242 | 243 | /* Begin PBXResourcesBuildPhase section */ 244 | CB8DCCC01865BBBD006A75E9 /* Resources */ = { 245 | isa = PBXResourcesBuildPhase; 246 | buildActionMask = 2147483647; 247 | files = ( 248 | CB8DCCDC1865BBBD006A75E9 /* Main_iPad.storyboard in Resources */, 249 | CBCD9B0D1869E0F2008F26DA /* center-highlighted@2x.png in Resources */, 250 | CB8DCCE11865BBBD006A75E9 /* Images.xcassets in Resources */, 251 | CB8DCCD91865BBBD006A75E9 /* Main_iPhone.storyboard in Resources */, 252 | CBCD9B0C1869E0F2008F26DA /* center-highlighted.png in Resources */, 253 | CBE2249A186875DB0018EF3D /* center@2x.png in Resources */, 254 | CBE22499186875DB0018EF3D /* center.png in Resources */, 255 | CB8DCCD01865BBBD006A75E9 /* InfoPlist.strings in Resources */, 256 | ); 257 | runOnlyForDeploymentPostprocessing = 0; 258 | }; 259 | CB8DCCE41865BBBD006A75E9 /* Resources */ = { 260 | isa = PBXResourcesBuildPhase; 261 | buildActionMask = 2147483647; 262 | files = ( 263 | ); 264 | runOnlyForDeploymentPostprocessing = 0; 265 | }; 266 | /* End PBXResourcesBuildPhase section */ 267 | 268 | /* Begin PBXSourcesBuildPhase section */ 269 | CB8DCCBE1865BBBD006A75E9 /* Sources */ = { 270 | isa = PBXSourcesBuildPhase; 271 | buildActionMask = 2147483647; 272 | files = ( 273 | CB8DCCDF1865BBBD006A75E9 /* ViewController.m in Sources */, 274 | CB29B3DE18AA2F2100EAE9AC /* PinterestLikeMenuItem.m in Sources */, 275 | CB8DCCD61865BBBD006A75E9 /* AppDelegate.m in Sources */, 276 | CB29B3DD18AA2F2100EAE9AC /* PinterestLikeMenu.m in Sources */, 277 | CB8DCCD21865BBBD006A75E9 /* main.m in Sources */, 278 | ); 279 | runOnlyForDeploymentPostprocessing = 0; 280 | }; 281 | CB8DCCE21865BBBD006A75E9 /* Sources */ = { 282 | isa = PBXSourcesBuildPhase; 283 | buildActionMask = 2147483647; 284 | files = ( 285 | ); 286 | runOnlyForDeploymentPostprocessing = 0; 287 | }; 288 | /* End PBXSourcesBuildPhase section */ 289 | 290 | /* Begin PBXTargetDependency section */ 291 | CB8DCCEC1865BBBD006A75E9 /* PBXTargetDependency */ = { 292 | isa = PBXTargetDependency; 293 | target = CB8DCCC11865BBBD006A75E9 /* PinterestLikeMenu */; 294 | targetProxy = CB8DCCEB1865BBBD006A75E9 /* PBXContainerItemProxy */; 295 | }; 296 | /* End PBXTargetDependency section */ 297 | 298 | /* Begin PBXVariantGroup section */ 299 | CB8DCCCE1865BBBD006A75E9 /* InfoPlist.strings */ = { 300 | isa = PBXVariantGroup; 301 | children = ( 302 | CB8DCCCF1865BBBD006A75E9 /* en */, 303 | ); 304 | name = InfoPlist.strings; 305 | sourceTree = ""; 306 | }; 307 | CB8DCCD71865BBBD006A75E9 /* Main_iPhone.storyboard */ = { 308 | isa = PBXVariantGroup; 309 | children = ( 310 | CB8DCCD81865BBBD006A75E9 /* Base */, 311 | ); 312 | name = Main_iPhone.storyboard; 313 | sourceTree = ""; 314 | }; 315 | CB8DCCDA1865BBBD006A75E9 /* Main_iPad.storyboard */ = { 316 | isa = PBXVariantGroup; 317 | children = ( 318 | CB8DCCDB1865BBBD006A75E9 /* Base */, 319 | ); 320 | name = Main_iPad.storyboard; 321 | sourceTree = ""; 322 | }; 323 | /* End PBXVariantGroup section */ 324 | 325 | /* Begin XCBuildConfiguration section */ 326 | CB8DCCF51865BBBD006A75E9 /* Debug */ = { 327 | isa = XCBuildConfiguration; 328 | buildSettings = { 329 | ALWAYS_SEARCH_USER_PATHS = NO; 330 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 331 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 332 | CLANG_CXX_LIBRARY = "libc++"; 333 | CLANG_ENABLE_MODULES = YES; 334 | CLANG_ENABLE_OBJC_ARC = YES; 335 | CLANG_WARN_BOOL_CONVERSION = YES; 336 | CLANG_WARN_CONSTANT_CONVERSION = YES; 337 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 338 | CLANG_WARN_EMPTY_BODY = YES; 339 | CLANG_WARN_ENUM_CONVERSION = YES; 340 | CLANG_WARN_INT_CONVERSION = YES; 341 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 342 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 343 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 344 | COPY_PHASE_STRIP = NO; 345 | GCC_C_LANGUAGE_STANDARD = gnu99; 346 | GCC_DYNAMIC_NO_PIC = NO; 347 | GCC_OPTIMIZATION_LEVEL = 0; 348 | GCC_PREPROCESSOR_DEFINITIONS = ( 349 | "DEBUG=1", 350 | "$(inherited)", 351 | ); 352 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 353 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 354 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 355 | GCC_WARN_UNDECLARED_SELECTOR = YES; 356 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 357 | GCC_WARN_UNUSED_FUNCTION = YES; 358 | GCC_WARN_UNUSED_VARIABLE = YES; 359 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 360 | ONLY_ACTIVE_ARCH = YES; 361 | SDKROOT = iphoneos; 362 | TARGETED_DEVICE_FAMILY = "1,2"; 363 | }; 364 | name = Debug; 365 | }; 366 | CB8DCCF61865BBBD006A75E9 /* Release */ = { 367 | isa = XCBuildConfiguration; 368 | buildSettings = { 369 | ALWAYS_SEARCH_USER_PATHS = NO; 370 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 371 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 372 | CLANG_CXX_LIBRARY = "libc++"; 373 | CLANG_ENABLE_MODULES = YES; 374 | CLANG_ENABLE_OBJC_ARC = YES; 375 | CLANG_WARN_BOOL_CONVERSION = YES; 376 | CLANG_WARN_CONSTANT_CONVERSION = YES; 377 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 378 | CLANG_WARN_EMPTY_BODY = YES; 379 | CLANG_WARN_ENUM_CONVERSION = YES; 380 | CLANG_WARN_INT_CONVERSION = YES; 381 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 382 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 383 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 384 | COPY_PHASE_STRIP = YES; 385 | ENABLE_NS_ASSERTIONS = NO; 386 | GCC_C_LANGUAGE_STANDARD = gnu99; 387 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 388 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 389 | GCC_WARN_UNDECLARED_SELECTOR = YES; 390 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 391 | GCC_WARN_UNUSED_FUNCTION = YES; 392 | GCC_WARN_UNUSED_VARIABLE = YES; 393 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 394 | SDKROOT = iphoneos; 395 | TARGETED_DEVICE_FAMILY = "1,2"; 396 | VALIDATE_PRODUCT = YES; 397 | }; 398 | name = Release; 399 | }; 400 | CB8DCCF81865BBBD006A75E9 /* Debug */ = { 401 | isa = XCBuildConfiguration; 402 | buildSettings = { 403 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 404 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 405 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 406 | GCC_PREFIX_HEADER = "PininterestLikeMenu/PinterestLikeMenu-Prefix.pch"; 407 | INFOPLIST_FILE = "PininterestLikeMenu/PinterestLikeMenu-Info.plist"; 408 | PRODUCT_NAME = PinterestLikeMenu; 409 | WRAPPER_EXTENSION = app; 410 | }; 411 | name = Debug; 412 | }; 413 | CB8DCCF91865BBBD006A75E9 /* Release */ = { 414 | isa = XCBuildConfiguration; 415 | buildSettings = { 416 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 417 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 418 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 419 | GCC_PREFIX_HEADER = "PininterestLikeMenu/PinterestLikeMenu-Prefix.pch"; 420 | INFOPLIST_FILE = "PininterestLikeMenu/PinterestLikeMenu-Info.plist"; 421 | PRODUCT_NAME = PinterestLikeMenu; 422 | WRAPPER_EXTENSION = app; 423 | }; 424 | name = Release; 425 | }; 426 | CB8DCCFB1865BBBD006A75E9 /* Debug */ = { 427 | isa = XCBuildConfiguration; 428 | buildSettings = { 429 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 430 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/PininterestLikeMenu.app/PininterestLikeMenu"; 431 | FRAMEWORK_SEARCH_PATHS = ( 432 | "$(SDKROOT)/Developer/Library/Frameworks", 433 | "$(inherited)", 434 | "$(DEVELOPER_FRAMEWORKS_DIR)", 435 | ); 436 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 437 | GCC_PREFIX_HEADER = "PininterestLikeMenu/PininterestLikeMenu-Prefix.pch"; 438 | GCC_PREPROCESSOR_DEFINITIONS = ( 439 | "DEBUG=1", 440 | "$(inherited)", 441 | ); 442 | INFOPLIST_FILE = "PininterestLikeMenuTests/PinterestLikeMenuTests-Info.plist"; 443 | PRODUCT_NAME = PinterestLikeMenuTests; 444 | TEST_HOST = "$(BUNDLE_LOADER)"; 445 | WRAPPER_EXTENSION = xctest; 446 | }; 447 | name = Debug; 448 | }; 449 | CB8DCCFC1865BBBD006A75E9 /* Release */ = { 450 | isa = XCBuildConfiguration; 451 | buildSettings = { 452 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 453 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/PininterestLikeMenu.app/PininterestLikeMenu"; 454 | FRAMEWORK_SEARCH_PATHS = ( 455 | "$(SDKROOT)/Developer/Library/Frameworks", 456 | "$(inherited)", 457 | "$(DEVELOPER_FRAMEWORKS_DIR)", 458 | ); 459 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 460 | GCC_PREFIX_HEADER = "PininterestLikeMenu/PininterestLikeMenu-Prefix.pch"; 461 | INFOPLIST_FILE = "PininterestLikeMenuTests/PinterestLikeMenuTests-Info.plist"; 462 | PRODUCT_NAME = PinterestLikeMenuTests; 463 | TEST_HOST = "$(BUNDLE_LOADER)"; 464 | WRAPPER_EXTENSION = xctest; 465 | }; 466 | name = Release; 467 | }; 468 | /* End XCBuildConfiguration section */ 469 | 470 | /* Begin XCConfigurationList section */ 471 | CB8DCCBD1865BBBD006A75E9 /* Build configuration list for PBXProject "PinterestLikeMenu" */ = { 472 | isa = XCConfigurationList; 473 | buildConfigurations = ( 474 | CB8DCCF51865BBBD006A75E9 /* Debug */, 475 | CB8DCCF61865BBBD006A75E9 /* Release */, 476 | ); 477 | defaultConfigurationIsVisible = 0; 478 | defaultConfigurationName = Release; 479 | }; 480 | CB8DCCF71865BBBD006A75E9 /* Build configuration list for PBXNativeTarget "PinterestLikeMenu" */ = { 481 | isa = XCConfigurationList; 482 | buildConfigurations = ( 483 | CB8DCCF81865BBBD006A75E9 /* Debug */, 484 | CB8DCCF91865BBBD006A75E9 /* Release */, 485 | ); 486 | defaultConfigurationIsVisible = 0; 487 | defaultConfigurationName = Release; 488 | }; 489 | CB8DCCFA1865BBBD006A75E9 /* Build configuration list for PBXNativeTarget "PinterestLikeMenuTests" */ = { 490 | isa = XCConfigurationList; 491 | buildConfigurations = ( 492 | CB8DCCFB1865BBBD006A75E9 /* Debug */, 493 | CB8DCCFC1865BBBD006A75E9 /* Release */, 494 | ); 495 | defaultConfigurationIsVisible = 0; 496 | defaultConfigurationName = Release; 497 | }; 498 | /* End XCConfigurationList section */ 499 | }; 500 | rootObject = CB8DCCBA1865BBBD006A75E9 /* Project object */; 501 | } 502 | -------------------------------------------------------------------------------- /PinterestLikeMenu.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PinterestLikeMenu 2 | =================== 3 | 4 | A kind of pop-up menu 5 | 6 | **How to:** 7 | 8 | First, the menu can be initialized with: 9 | 10 | PinterestLikeMenuItem *item0 = [[PinterestLikeMenuItem alloc] initWithImage:[UIImage imageNamed:@"center"] 11 | selctedImage:[UIImage imageNamed:@"center-highlighted"] 12 | selectedBlock:^(void) { 13 | NSLog(@"item 0 selected"); 14 | }]; 15 | PinterestLikeMenuItem *item1 = [[PinterestLikeMenuItem alloc] initWithImage:[UIImage imageNamed:@"center"] 16 | selctedImage:[UIImage imageNamed:@"center-highlighted"] 17 | selectedBlock:^(void) { 18 | NSLog(@"item 1 selected"); 19 | }]; 20 | PinterestLikeMenuItem *item2 = [[PinterestLikeMenuItem alloc] initWithImage:[UIImage imageNamed:@"center"] 21 | selctedImage:[UIImage imageNamed:@"center-highlighted"] 22 | selectedBlock:^(void) { 23 | NSLog(@"item 2 selcted"); 24 | }]; 25 | NSArray *submenus = @[item0, item1, item2]; 26 | 27 | self.menu = [[PinterestLikeMenu alloc] initWithSubmenus:submenus]; 28 | 29 | To use this pop-up menu, you should add a long press gesture recognizer to the target view with: 30 | 31 | - (void)popPinterestMenu:(UIGestureRecognizer *)gesture 32 | { 33 | CGPoint location = [gesture locationInView:self.view.window]; 34 | if (gesture.state == UIGestureRecognizerStateBegan) 35 | { 36 | // set the start point where the menu showing up 37 | self.menu.startPoint = location; 38 | [self.menu show]; 39 | } 40 | else if (gesture.state == UIGestureRecognizerStateChanged) 41 | { 42 | [self.menu updataLocation:location]; 43 | } 44 | else 45 | { 46 | [self.menu finished]; 47 | self.menu = nil; 48 | } 49 | } 50 | 51 | 52 | **A Quick Peek** 53 | 54 | ![screenshots](https://f.cloud.github.com/assets/4316898/1829452/50e4a22c-72b8-11e3-9158-7f65e7bedd92.gif) 55 | --------------------------------------------------------------------------------