YXPickerView 1.2.2

YXPickerView 1.2.2

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Mar 2021

Maintained by caoyunxiao.



  • By
  • Matej caoyunxiao

YXPickerView

项目中经常会用到选择器,比如省市区选择、筛选项选择、日期选择、时间选择等等,此项目做了一个封装以方便使用。

通过cocoapods找到它:pod search YXPickerView 使用: pod 'YXPickerView' pod install

1、自定义选择使用示例

[[YXPickerManager shareManager] showCustomPickerViewDataArray:@[@"1",@"2",@"3",@"4"] selectIndex:3 confirm:^(NSString *title, NSInteger index) {
NSLog(@"%@ - %ld",title,index);
} cancel:^{
NSLog(@"取消");
}];

2、省市区选择使用示例

[[YXPickerManager shareManager] showAddressPickerViewSelected:@"上海市-市辖区-闵行区" confirm:^(NSString *address, NSString *zipcode) {
NSLog(@"%@ - %@",address,zipcode);
} cancel:^{
NSLog(@"取消");
}];

3、日期选择使用示例

[[YXPickerManager shareManager] showDatePickerViewMinimumDate:nil maximumDate:nil defaultDate:@"2019-05-08" confirm:^(NSString *dateStr, NSDate *date) {
NSLog(@"%@ - %@",dateStr,date);
} cancel:^{
NSLog(@"取消");
}];

4、时间选择使用示例

[[YXPickerManager shareManager] showTimePickerViewMinimumDate:nil maximumDate:nil defaultDate:@"15:00:00" confirm:^(NSString *dateStr, NSDate *date) {
NSLog(@"%@ - %@",dateStr,date);
} cancel:^{
NSLog(@"取消");
}];

5、日期和时间选择使用示例

[[YXPickerManager shareManager] showDateAndTimePickerViewMinimumDate:nil maximumDate:nil defaultDate:@"2019-08-08 12:00:00" confirm:^(NSString *dateStr, NSDate *date) {
NSLog(@"%@ - %@",dateStr,date);
} cancel:^{
NSLog(@"取消");
}];

6、仿微信弹框

YXActionSheetModel *photoModel = [YXActionSheetModel title:@"相册" color:[UIColor blackColor]];
[photoModel setClickBlock:^(NSInteger index) {
    NSLog(@"点击");
 }];
YXActionSheetModel *cameraModel = [YXActionSheetModel title:@"相机" color:[UIColor blackColor]];
[cameraModel setClickBlock:^(NSInteger index) {
    NSLog(@"点击");
}];
YXActionSheetModel *viewModel = [YXActionSheetModel title:@"查看大图" color:[UIColor blackColor]];
[viewModel setClickBlock:^(NSInteger index) {
    NSLog(@"点击");
 }];
[[YXPickerManager shareManager] showActionSheetView:@[photoModel,cameraModel,viewModel] title:@"设置个人头像"];

7、自定义UIView、UIViewController

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
view.backgroundColor = [UIColor redColor];
[[YXPickerManager shareManager] showCustomView:view cancel:^{
    NSLog(@"取消");
}];
SecondViewController *vc = [[SecondViewController alloc] init];
vc.title = @"测试";
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
[[YXPickerManager shareManager] showCustomVc:nav contentHeight:400 cancel:^{
    NSLog(@"取消");
}];

End