第三库下载地址:http://code4app.com/ios/Popup-Grid-Menu/51e3874c6803fac50d000001
RNGridMenu的demo讲解很详细,自己敲一遍也能能够马上会用。
共有两个类:RNGridMenu和RNGridMenuItem。前面这个类用来初始化显示在视图控制器上的对象,后面的类是一个视图控制器。
用法:
(1)创建一个数组
弹出的列表;弹出的图片和按钮介绍,图片和按钮介绍可以二选其一。如果弹出列表,数组中放字符串对象。如果弹出的图片,数组中存储RNGridMenuItem
对象。
(2)初始化RNGridMenuItem
// Initialize the menu with a list of menu items.
// Note: this changes the view to style RNGridMenuStyleList if no images are supplied
- (instancetype)initWithItems:(NSArray *)items;
// Initialize the menu with a list of images. Maintains style RNGridMenuStyleGrid
- (instancetype)initWithImages:(NSArray *)images;
// Initialize the menu with a list of titles. Note: this changes the view to style RNGridMenuStyleList since no images are supplied
- (instancetype)initWithTitles:(NSArray *)titles;
(3)
// Show the menu
- (void)showInViewController:(UIViewController *)parentViewController center:(CGPoint)center;
如何知道用户点击了哪一个图片?
用到它的代理方法。说到这里有没有这里有没有觉得这个特别和UIAlertView相似的用法
@protocol RNGridMenuDelegate <NSObject>
@optional
- (void)gridMenu:(RNGridMenu *)gridMenu willDismissWithSelectedItem:(RNGridMenuItem *)item atIndex:(NSInteger)itemIndex;
- (void)gridMenuWillDismiss:(RNGridMenu *)gridMenu;
@end