TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Oct 2016 |
Maintained by Victor Zhang.
ZRPopoverView is a popover view that pop UIView with a list of button by customising events and contents.
1.If you like invoke this events by block so that Choose No.1 .
2.If you like invoke this events by delegate so that Choose No.2.
CocoaPods is a dependency manager for Objective-C , which anutomates and simplifies the process of using 3rd-party libraries like ZRPopoverView in you projects.
$ gem install cocoapods
Cocoapods 1.0.0+ is required to build ZRPopoverView 1.5
To integrate ZRPopoverView into your Xcode project using Cocoapods, specify it in your Podfile
:
platform :ios, '7.0'
pod 'ZRPopoverView', '~>1.5'
Then, run the following command:
$ pod install
NSArray *menus = @[
@{ kZRPopoverViewTitle: @"Group Chat", kZRPopoverViewIcon: @"btn_Inter" },
@{ kZRPopoverViewTitle: @"Add Contacts", kZRPopoverViewIcon: @"btn_notice" },
@{ kZRPopoverViewTitle: @"Scan QR Code", kZRPopoverViewIcon: @"btn_Inter" },
@{ kZRPopoverViewTitle: @"Money", kZRPopoverViewIcon: @"btn_Tele" }
];
ZRPopoverView *popover = [[ZRPopoverView alloc] initWithStyle:ZRPopoverViewStyleDefault menus:menus position:ZRPopoverViewPositionLeftOfTop];
[popover showWithController:self completion:^(int index) {
NSLog(@"index = %d", index );
}];
//You can add `ZRPopoverViewDelegate` to conform this protocol
//Only one method need to implement `- (void)popoverView:(ZRPopoverView *)popoverView didClick:(int)index;`
NSArray *menus = @[
@{ kZRPopoverViewTitle: @"创建群聊" },
@{ kZRPopoverViewTitle: @"私信" },
@{ kZRPopoverViewTitle: @"发送短信" },
@{ kZRPopoverViewTitle: @"直接拨打电话" },
@{ kZRPopoverViewTitle: @"VoIP电话" }
];
ZRPopoverView *popover = [[ZRPopoverView alloc] initWithStyle:ZRPopoverViewStyleLightContent menus:menus position:ZRPopoverViewPositionCenterOfTop];
popover.delegate = self;
[popover showWithController:self];
NSArray *menus = @[
@{ kZRPopoverViewTitle: @"Payment" , kZRPopoverViewIcon: @"btn_Install" },
@{ kZRPopoverViewTitle: @"Using Paypal" , kZRPopoverViewIcon: @"btn_Install" },
@{ kZRPopoverViewTitle: @"For Messenger" , kZRPopoverViewIcon: @"btn_Install" },
@{ kZRPopoverViewTitle: @"Say Hello To" , kZRPopoverViewIcon: @"btn_Install" },
@{ kZRPopoverViewTitle: @"AR/VR Store" , kZRPopoverViewIcon: @"btn_Install" }
];
ZRPopoverView *popover = [[ZRPopoverView alloc] initWithStyle:ZRPopoverViewStyleLightContent menus:menus position:ZRPopoverViewPositionRightOfTop];
[popover showWithController:self completion:^(int index) {
NSLog(@"index = %d", index );
}];
ZRPopoverView是一个非常好用的弹出菜单,使用者可以自定义内容和事件.
1.事件的回调,喜欢block的,请使用第一种方式
2.事件的回调,喜欢delegate的,请使用第二种方式
CocoaPods Cocoapods是一个Objective-C的库文件依赖管理器,它会自动的,简单化的集成第三方库到你的项目,例如ZRPopoverView。
$ gem install cocoapods
Cocoapods 1.0.0+ is required to build ZRPopoverView 1.5
使用Cocoapods把ZRPopoverView库集成到你的项目,podfile文件内容如下
source 'https://github.com/VictorZhang2014/ZRPopoverView'
platform :ios, '7.0'
pod 'ZRPopoverView', '~>1.5'
接着,运行以下命令
$ pod install
NSArray *menus = @[
@{ kZRPopoverViewTitle: @"Group Chat", kZRPopoverViewIcon: @"btn_Inter" },
@{ kZRPopoverViewTitle: @"Add Contacts", kZRPopoverViewIcon: @"btn_notice" },
@{ kZRPopoverViewTitle: @"Scan QR Code", kZRPopoverViewIcon: @"btn_Inter" },
@{ kZRPopoverViewTitle: @"Money", kZRPopoverViewIcon: @"btn_Tele" }
];
ZRPopoverView *popover = [[ZRPopoverView alloc] initWithStyle:ZRPopoverViewStyleDefault menus:menus position:ZRPopoverViewPositionLeftOfTop];
[popover showWithController:self completion:^(int index) {
NSLog(@"index = %d", index );
}];
//添加`ZRPopoverViewDelegate`协议并且遵循该协议的方法
//只需要实现此方法`- (void)popoverView:(ZRPopoverView *)popoverView didClick:(int)index;`
NSArray *menus = @[
@{ kZRPopoverViewTitle: @"创建群聊" },
@{ kZRPopoverViewTitle: @"私信" },
@{ kZRPopoverViewTitle: @"发送短信" },
@{ kZRPopoverViewTitle: @"直接拨打电话" },
@{ kZRPopoverViewTitle: @"VoIP电话" }
];
ZRPopoverView *popover = [[ZRPopoverView alloc] initWithStyle:ZRPopoverViewStyleLightContent menus:menus position:ZRPopoverViewPositionCenterOfTop];
popover.delegate = self;
[popover showWithController:self];
NSArray *menus = @[
@{ kZRPopoverViewTitle: @"Payment" , kZRPopoverViewIcon: @"btn_Install" },
@{ kZRPopoverViewTitle: @"Using Paypal" , kZRPopoverViewIcon: @"btn_Install" },
@{ kZRPopoverViewTitle: @"For Messenger" , kZRPopoverViewIcon: @"btn_Install" },
@{ kZRPopoverViewTitle: @"Say Hello To" , kZRPopoverViewIcon: @"btn_Install" },
@{ kZRPopoverViewTitle: @"AR/VR Store" , kZRPopoverViewIcon: @"btn_Install" }
];
ZRPopoverView *popover = [[ZRPopoverView alloc] initWithStyle:ZRPopoverViewStyleLightContent menus:menus position:ZRPopoverViewPositionRightOfTop];
[popover showWithController:self completion:^(int index) {
NSLog(@"index = %d", index );
}];