NBPopMenu 0.2.5

NBPopMenu 0.2.5

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2017

Maintained by shiyingfeng.



NBPopMenu 0.2.5

  • By
  • shiyingfeng




示例图片

image

介绍

NBPopMenu支持弹出框定制.非常方便使用.使用简单.代码块集中.

使用方式

1.最简洁的使用方式
NSArray *arr = @[@"1",@"2",@"3",@"4"];
[NBPopMenu showPopMenuWithItems:arr fromView:sender updateWithConfig:nil clickItem:nil];
2.回调的使用方式
NSArray *arr = @[@"1",@"2",@"3",@"4"];
[NBPopMenu showPopMenuWithItems:arr fromView:sender updateWithConfig:nil clickItem:^(NSInteger index) {
NSLog(@"点击了%zd",index);
}];
3.默认初始化一个选择(需配合使用)
static NSInteger ind = 2;
NSArray *arr = @[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10"];
UITouch *t = touches.anyObject;
CGPoint p = [t locationInView: self.view];
[NBPopMenu showPopMenuWithItems:arr fromPoint:p updateWithConfig:^(NBPopMenuConfig *config) {
config.popMenuVisibleItemCount = 4;
config.popMenuOffset = 5;
config.popMenuSelectIndex = ind;
config.popMenuSelectedBgColor = [UIColor yellowColor];
} clickItem:^(NSInteger index) {
ind = index;
}];
4.通过传入字典弹出popMenu
NSDictionary *itemDict = @{@"发起群聊":@"chat_img_groupchat",
@"添加朋友":@"home_img_my",
@"扫一扫":@"home_img_scan"
};

[NBPopMenu showPopMenuWithDict:itemDict fromPoint:sender.center updateWithConfig:^(NBPopMenuConfig *config) {
config.popMenuBackgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
config.popMenuTextColor = [UIColor whiteColor];
} clickItem:^(NSInteger index) {
NSLog(@"点击了%zd",index);
}];

安装

NBPopMenu 可以通过Pods安装 CocoaPods.

pod 'NBPopMenu'

联系方式

左手边是幸福, [email protected]