類似于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 = @"非死book"; break; case 1: imageName = @"推ter"; 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 = @"非死book Selected"; break; case 1: msg = @"推ter 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];
}</pre>
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!