一、效果预览图如下:
二、用法
1.日期选择器调用(有多种调用方式,看demo即可)
[[MOFSPickerManager shareManger].datePicker showWithTitle:@"选择日期" commitTitle:@"确定" cancelTitle:@"取消" selectedDate:selectedDate minDate:nil maxDate:nil datePickerMode:UIDatePickerModeDate commitBlock:^(NSDate * _Nullable date) {
NSLog(@"%@", [df stringFromDate:date]); } cancelBlock:^{
}];
参数说明
* @param title : 中间标题,一般为nil
* @param cancelTitle : 左边标题 “取消”
* @param commitTitle : 右边标题 “确定”
* @param selectedDate : 默认选中日期
* @param minDate : 可选择的最小日期,不限制则为nil
* @param maxDate : 可选择的最大日期,不限制则为nil
* @param model : UIDatePickerMode 日期模式,有四种 UIDatePickerModeTime, UIDatePickerModeDate, UIDatePickerModeDateAndTime, UIDatePickerModeCountDownTimer
2.普通选择器调用
[[MOFSPickerManager shareManger].pickView showWithDataArray:@[@"疾风剑豪",@"刀锋意志",@"诡术妖姬",@"狂战士"] title:nil commitBlock:^(id _Nullable model) {
} cancelBlock:^{
}];
传入自定义model,keyMapper为要显示的该Model对应的key
Model *a = [Model new];
a.age = 17;
a.name = @"疾风剑豪";
a.userId = 0001;
Model *b = [Model new];
b.age = 18;
b.name = @"刀锋意志";
b.userId = 0002;
Model *c = [Model new];
c.age = 22;
c.name = @"诡术妖姬";
c.userId = 0003;
[[MOFSPickerManager shareManger].pickView showWithDataArray:@[a, b, c] keyMapper:@"name" title:@"选择英雄" commitBlock:^(id _Nullable model) {
Model *m = (Model *)model;
lb.text = m.name;
NSLog(@"%@-%zd", m.name, m.userId);
} cancelBlock:^{
}];
3.地址选择器调用
[[MOFSPickerManager shareManger].addressPicker showWithTitle:@"选择地址" commitTitle:@"确定" cancelTitle:@"取消" commitBlock:^(MOFSAddressSelectedModel * _Nullable selectedModel) {
lb.text = [NSString stringWithFormat:@"%@-%@-%@", selectedModel.provinceName, selectedModel.cityName, selectedModel.districtName];
} cancelBlock:^{
}];
地址选择器附带根据地址查询区域码或者根据区域码查询地址功能:
用法:
①根据区域码查询地址等信息
[[MOFSPickerManager shareManger].addressPicker searchType:MOFSAddressSearchTypeByZipcode keyModel:[MOFSAddressSelectedModel initWithProvinceZipcode:@"450000" cityZipcode:@"450900" districtZipcode:@"450921"] block:^(MOFSSearchAddressModel * _Nullable result) {
}];
②根据地址查询区域码等信息
[[MOFSPickerManager shareManger].addressPicker searchType:MOFSAddressSearchTypeByAddress keyModel:[MOFSAddressSelectedModel initWithProvinceName:@"广西壮族自治区" cityName:@"玉林市" districtName:@"容县"] block:^(MOFSSearchAddressModel * _Nullable result) {
}];