类似于Pinterest的上下文菜单iOS控件:GHContextMenu

分享到:
GHContextMenu就一个类似于Pinterest的上下文菜单iOS控件。
// Creating
GHContextMenuView* overlay = [[GHContextMenuView alloc] init];
overlay.dataSource = self;
overlay.delegate = self;
UILongPressGestureRecognizer* _longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:overlay action:@selector(longPressDetected:)];
[self.view addGestureRecognizer:_longPressRecognizer];
// Implementing data source methods
- (NSInteger) numberOfMenuItems
{
return 3;
}
-(UIImage*) imageForItemAtIndex:(NSInteger)index
{
NSString* imageName = nil;
switch (index) {
case 0:
imageName = @"facebook";
break;
case 1:
imageName = @"twitter";
break;
case 2:
imageName = @"google-plus";
break;
default:
break;
}
return [UIImage imageNamed:imageName];
}
- (void) didSelectItemAtIndex:(NSInteger)selectedIndex forMenuAtPoint:(CGPoint)point
{
NSString* msg = nil;
switch (selectedIndex) {
case 0:
msg = @"Facebook Selected";
break;
case 1:
msg = @"Twitter Selected";
break;
case 2:
msg = @"Google Plus Selected";
break;
default:
break;
}
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}

类似于Pinterest的上下文菜单iOS控件:GHContextMenuBackgroundImageBackgroundImage

项目主页:http://www.open-open.com/lib/view/home/1392685393256

昵    称:
验证码:

相关文档: