MXPickerView 是一个 对 UIPickerView 和 UIDatePicker的封装, 三行代码实现`年月日`的弹出控件

代码demo已在Github开源, MXPickerView 如果能帮助到您,可以点个星star哈,谢谢!

MXPickerView 是一个 对 UIPickerViewUIDatePicker的封装, 三行代码实现年月日的弹出控件

屏幕截图

MXPickerViewModeCustom MXPickerViewModeDD MXPickerViewModeDD_DD MXPickerViewModeMM
MXPickerViewModeCustom
MXPickerViewModeDD
MXPickerViewModeDD_DD
MXPickerViewModeMM
MXPickerViewModeMM_MM MXPickerViewModeMM_DD MXPickerViewModeMMDD_MMDD MXPickerViewModeYYYY
MXPickerViewModeMM_MM
MXPickerViewModeMM_DD
MXPickerViewModeMMDD_MMDD
MXPickerViewModeYYYY
MXPickerViewModeYYYY_YYYY MXPickerViewModeYYYY_MM MXPickerViewModeYYYYMM_YYYYMM MXPickerViewModeYYYYMMDD_YYYYMMDD
MXPickerViewModeYYYY_YYYY
MXPickerViewModeYYYY_MM
MXPickerViewModeYYYYMM_YYYYMM
MXPickerViewModeYYYYMMDD_YYYYMMDD
MXPickerViewModeTime MXPickerViewModeDate MXPickerViewModeDateAndTime MXPickerViewModeCountDownTimer
MXPickerViewModeTime
MXPickerViewModeDate
MXPickerViewModeDateAndTime
MXPickerViewModeCountDownTimer

可自定义属性

ScreenshotsInDemoxxxxxxxxxx Attribute Name Example
image
NSDictionary<NSAttributedStringKey, id> *barBtnItemTitleTextAttributes; pickerView.barBtnItemTitleTextAttributes = @{NSFontAttributeName: [UIFont boldSystemFontOfSize:14], NSForegroundColorAttributeName: [UIColor redColor]}
image
NSString *yearLocale, *monthLocale, *dayLocale; pickerView.yearLocale = @"年";
pickerView.monthLocale = @"月";
pickerView.dayLocale = @"号";
image

BOOL toolBarPositionBottom;

//默认为NO,返回确定按钮显示在顶部,
当设为YES,返回确定按钮显示在底部

pickerView.toolBarPositionBottom = YES;
image

NSArray<NSString *> *topTipBarTitles;

//不为nil时, toolBarPositionBottom
会自动设置为YES,底部显示返回确定按钮,
顶部显示topTipBarTitles, 如开始日期 - 结束日期

pickerView.topTipBarTitles = @[@"开始日期", @"结束日期"];
image

CGFloat topTipBarH, toolBarH;

pickerView.topTipBarH = 50;
pickerView.toolBarH = 30;
// 底部显示返回确定按钮,顶部显示开始日期 - 结束日期
topTipBarTitles一栏高度,默认是44;
返回确定按钮一栏高度,默认是44

pickerView.topTipBarTitles = @[@"开始日期", @"结束日期"];
image

BOOL showsDescending;

// 默认升序,结果为12, 1, 2, 3... 11, 12,
当为降序,结果为12, 11, 10, ...4, 3, 2, 1, 12, 仅支持mode是日期类的,如MXPickerViewModeDD...

pickerView.showsDescending = YES;
image

id selectedTitleOrCustomModels;

//如果值不为空,则pickerView会把当前值选中,
demo中是把上一个值记录为selectedTitleOrCustomModels
当模式为MXPickerViewModeCustom, selectedTitleOrCustomModels 应该为customModels, 是一个 NSArray数组类型, 如 @[@"0-1", @"1-2", @"2-3"]
当模式为日期一类的,如MXPickerViewModeDD..., selectedTitleOrCustomModels应该为selectedTitle, 是一个用空格拼接的NSString数组类型, 格式类似于2018 12 12
当模式为UIDatePicker一类的, 如MXPickerViewModeDateAndTime, selectedTitleOrCustomModels 不应该传, 默认值总是nil!

//当模式为MXPickerViewModeCustom
pickerView.selectedTitleOrCustomModels = @[@"0-1", @"1-2", @"2-3"];

//当模式为日期一类的,如MXPickerViewModeDD...,
pickerView.selectedTitleOrCustomModels = @"12月 1号"
image
NSDate *minimumDate;
NSDate *maximumDate;
//仅支持mode是日期类的,如MXPickerViewModeDD...


//创建从(今天 - 今天 + 10天),如(1号 - 10号)的列表

//方式1,设置中间的时间间隔,超过当月的最大天数,
代码内部会取余deltaBetweenMaxAndMin%最大天数
推荐方式一
pickerView.minimumDate = [NSDate date];
pickerView.deltaBetweenMaxAndMin = 10;

//方式二, 设置最小日期最大日期,超过
当月的最大天数,代码内部会取余
deltaBetweenMaxAndMin%最大天数
pickerView.minimumDate = [NSDate date];
pickerView.maximumDate = [NSDate dateWithTimeInterval:10 * 24 * 60 * 60 sinceDate:pickerView.minimumDate];

image

CGFloat componentWidth;
//设置每个component的宽度,等宽,如果不设置,
默认为pickerView.bounds.size.width/numberOfComponents

pickerView.componentWidth = 100;
//每一列component列宽都为100
image

CGFloat componentRowHeight;
//设置每个component的行高,如果不设置,默认为40

pickerView.componentRowHeight = 100;
image

CGFloat (^configPickerViewWidthForComponentBlock)(MXPickerView *mxPickerView, UIPickerView *pickerView, NSInteger component)
//为每个component设置不同的宽度,相同的可以直接设置pickerView.componentWidth = xx

```pickerView.configPickerViewWidthForComponentBlock = ^CGFloat(MXPickerView *mxPickerView, UIPickerView *pickerView, NSInteger component) { return (component == 0 component == 3) ? 80 : (mxPickerView.bounds.size.width - 2 * 80)/4;};```
image

CGFloat(^configPickerViewRowHeightForComponentBlock)(MXPickerView *mxPickerView, UIPickerView *pickerView, NSInteger component)
//为每个component设置相同的行高, 等价于pickerView.componentRowHeight = xx

pickerView.configPickerViewRowHeightForComponentBlock = ^CGFloat(MXPickerView *mxPickerView, UIPickerView *pickerView, NSInteger component) {return 100;};
image

NSString * (^configPickerViewTitleForRowForComponentBlock)(MXPickerView *mxPickerView, UIPickerView *pickerView, NSInteger row, NSInteger component);
//设置每一行的title

pickerView.configPickerViewTitleForRowForComponentBlock = ^NSString *(MXPickerView *mxPickerView, UIPickerView *pickerView, NSInteger row, NSInteger component) {return @"row content";};
image

NSAttributedString * (^configPickerViewAttributedTitleForRowForComponentBlock)(MXPickerView *mxPickerView, UIPickerView *pickerView, NSInteger row, NSInteger component)
//设置每一行的attributedTitle

pickerView.configPickerViewAttributedTitleForRowForComponentBlock = ^NSAttributedString *(MXPickerView *mxPickerView, UIPickerView *pickerView, NSInteger row, NSInteger component) {return [[NSAttributedString alloc] initWithString:@"attributed title" attributes:@{NSForegroundColorAttributeName:[UIColor purpleColor]}];};
image

void (^configPickerViewContentLabelAppearanceForRowForComponentBlock)(MXPickerView *mxPickerView, UIPickerView *pickerView, UILabel *contentLabel, NSInteger row, NSInteger component);
//设置 content label 的样式,如字体,文字对齐方式,背景颜色等...

pickerView.configPickerViewContentLabelAppearanceForRowForComponentBlock = ^(MXPickerView *mxPickerView, UIPickerView *pickerView, UILabel *contentLabel, NSInteger row, NSInteger component){ contentLabel.backgroundColor = [UIColor yellowColor];//黄色 contentLabel.textAlignment = NSTextAlignmentRight;};//右对齐
image

UIView * (^configPickerViewViewForRowForComponentBlock)(MXPickerView *mxPickerView, UIPickerView *pickerView, NSInteger row, NSInteger component, UIView *reusingView);
//自定义在component中的contentView

pickerView.configPickerViewViewForRowForComponentBlock = ^UIView *(MXPickerView *mxPickerView, UIPickerView *pickerView, NSInteger row, NSInteger component, UIView *reusingView) {return [UIButton buttonWithType:UIButtonTypeContactAdd];//返回UIButtonTypeContactAdd};

如何使用

MXPickerViewModeCustom

    [MXPickerView showWithSize:CGSizeMake(self.view.bounds.size.width, 200) pickerViewMode:MXPickerViewModeCustom updateBlock:^(MXPickerView *pickerView, MXPickerViewMode pickerViewMode, id uiDatePickerOrUIPickerView) {
        // 设置`contentlLabel`文字
        pickerView.modelsM = (id)@[@[@"0-0", @"0-1", @"0-2", @"0-3"], @[@"1-0", @"1-1", @"1-2", @"1-3"], @[@"2-0", @"2-1", @"2-2", @"2-3"]];
        //pickerView.selectedTitleOrCustomModels = @[@"0-1", @"1-2", @"2-3"];
        pickerView.selectedTitleOrCustomModels = (NSArray *)self.selectedTitleOrCustomModelsDictM[@(pickerViewMode)];
        pickerView.configPickerViewTitleForRowForComponentBlock = ^NSString *(MXPickerView *mxPickerView, UIPickerView *pickerView, NSInteger row, NSInteger component) {
            return [NSString stringWithFormat:@"%@", mxPickerView.modelsM[component][row]];
        };
        //pickerView.barBtnItemTitleTextAttributes = @{NSFontAttributeName: [UIFont boldSystemFontOfSize:14], NSForegroundColorAttributeName: [UIColor redColor]};
        pickerView.doneButtonDidClickBlock = ^(MXPickerViewMode pickerViewMode, CGFloat countDownDuration, NSDate *date, id selectedTitleOrCustomModels) {
            NSLog(@"selectedTitleOrCustomModels: %@", selectedTitleOrCustomModels);
            self.selectedTitleOrCustomModelsDictM[@(pickerViewMode)] = (NSArray *)selectedTitleOrCustomModels;
        };
        /*// 设置`contentlLabel`属性字符串,打开注释
         pickerView.configPickerViewAttributedTitleForRowForComponentBlock = ^NSAttributedString *(MXPickerView *mxPickerView, UIPickerView *pickerView, NSInteger row, NSInteger component) {
            return [[NSAttributedString alloc] initWithString:@"attributed title" attributes:@{NSForegroundColorAttributeName:[UIColor purpleColor]}];
        };*/
        /*// 需要为不同`component`返回不一样列高时,打开注释
         pickerView.configPickerViewWidthForComponentBlock = ^CGFloat(MXPickerView *mxPickerView, UIPickerView *pickerView, NSInteger component) {
             return (component == 0 || component == 3) ? 70 : (self.view.bounds.size.width - 2 * 80)/4;
         };*/
        /*// 为每个`component`设置不同的行高, 相同的可以直接设置`pickerView.componentRowHeight = xx`
         pickerView.configPickerViewRowHeightForComponentBlock = ^CGFloat(MXPickerView *mxPickerView, UIPickerView *pickerView, NSInteger component) {
             return 100;
         };*/
        //pickerView.componentRowHeight = 100; //默认每一列`component`行高都为40,当所有的`component`行高相等时,可统一设置, 相当于`tableView.rowHeight`
        //pickerView.toolBarPositionBottom = YES; //默认为`NO`,`返回`和`确定`按钮显示在顶部,当设为`YES`,`返回`和`确定`按钮显示在底部
        //pickerView.topTipBarTitles = @[@"开始日期", @"结束日期"]; //不为`nil`时,`toolBarPositionBottom`会自动设置为`YES`,底部显示`返回`和`确定`按钮,顶部显示`开始日期 - 结束日期`
        //pickerView.topTipBarH = 50; //`topTipBarTitles`一栏高度,默认是44
        //pickerView.toolBarH = 30; //`返回`和`确定`按钮一栏高度,默认是44
        //pickerView.backgroundColor = [UIColor lightGrayColor];
        /*//自定义在`component`中的`contentView`
         pickerView.configPickerViewViewForRowForComponentBlock = ^UIView *(MXPickerView *mxPickerView, UIPickerView *pickerView, NSInteger row, NSInteger component, UIView *reusingView) {
             return [UIButton buttonWithType:UIButtonTypeContactAdd];
        };*/
        // 想设置`contentLabel`的各个属性,实现`appearance block`
        pickerView.configPickerViewContentLabelAppearanceForRowForComponentBlock = ^(MXPickerView *mxPickerView, UIPickerView *pickerView, UILabel *contentLabel, NSInteger row, NSInteger component) {
            contentLabel.backgroundColor = [UIColor yellowColor];
            contentLabel.textAlignment = NSTextAlignmentRight;
         };
        /*pickerView.datePickerDidChangeBlock = ^(MXPickerViewMode pickerViewMode, CGFloat countDownDuration, NSDate *date, NSString *selectedTitle) {
            NSLog(@"pickerViewMode\n: %ld, countDownDuration\n: %f, date\n: %@, selectedTitle\n: %@", pickerViewMode, countDownDuration, date, selectedTitle);
        };*/
    }];

其他 date Mode

MXPickerViewModeDD
MXPickerViewModeDD_DD
MXPickerViewModeMM
MXPickerViewModeMM_MM
MXPickerViewModeMM_DD
MXPickerViewModeMMDD_MMDD
MXPickerViewModeYYYY
MXPickerViewModeYYYY_YYYY
MXPickerViewModeYYYY_MM
MXPickerViewModeYYYYMM_YYYYMM
MXPickerViewModeYYYYMMDD_YYYYMMDD

[MXPickerView showWithSize:CGSizeMake(self.view.bounds.size.width, 200) pickerViewMode:mode updateBlock:^(MXPickerView *pickerView, MXPickerViewMode pickerViewMode, id uiDatePickerOrUIPickerView) {
        switch (mode) {
            case MXPickerViewModeDD:
            case MXPickerViewModeDD_DD: {
                //创建从(今天 - 今天 + 10天),如(1号 - 10号)的列表,方式1和方式2结果一样
                //方式1,设置中间的时间间隔,超过当月的`最大天数`,代码内部会取余`deltaBetweenMaxAndMin%最大天数`,推荐方式一,方式二需要算日期,麻烦
                pickerView.minimumDate = [NSDate date];
                pickerView.deltaBetweenMaxAndMin = 10;
                /*
                 //方式2, 设置`最小日期`和`最大日期`,超过当月的`最大天数`,代码内部会取余`deltaBetweenMaxAndMin%最大天数`
                 pickerView.minimumDate = [NSDate date];
                 pickerView.maximumDate = [NSDate dateWithTimeInterval:10 * 24 * 60 * 60 sinceDate:pickerView.minimumDate];
                 */
                //方式3,什么都不写,全部使用默认值,1号 - 当月最大天数,`pickerView.deltaBetweenMaxAndMin = 当月最大天数`;//会根据当前模式设置默认值,`MXPickerViewModeDD_DD`会自动算当月最大几号,以及闰年
                //
                break;
            }
            case MXPickerViewModeMM:
            case MXPickerViewModeMM_MM: {
                //创建从(今月 - 今月 + 10月),如(1月 - 10月)的列表,方式1和方式2结果一样,推荐方式一,方式二需要算日期,麻烦
                //方式1,设置`最小日期`和`中间的时间间隔`,超过12,代码内部会取余`deltaBetweenMaxAndMin%12`
                pickerView.minimumDate = [NSDate date];
                pickerView.deltaBetweenMaxAndMin = 10;
                /*
                 //方式2, 设置`最小日期`和`最大日期`,超过12代码内部会取余`deltaBetweenMaxAndMin%12`
                 pickerView.minimumDate = [NSDate date];
                 pickerView.maximumDate = [NSDate dateWithTimeInterval:10 * 60 * 60 sinceDate:pickerView.minimumDate];
                 */
                //方式3,什么都不写,全部使用默认值 1月 - 12月,`pickerView.deltaBetweenMaxAndMin = 12`;//会根据当前模式设置默认值,`MXPickerViewModeMM_MM`则为12
                break;
            }
            case MXPickerViewModeMM_DD: // 1月1号
            case MXPickerViewModeMMDD_MMDD: {
                //创建从(今月1号 -(今月 + 10)31号)的列表,如(1月1号 - 10月31号),方式1和方式2结果一样,推荐方式一,方式二需要算日期,麻烦
                //方式1,设置中间的时间间隔,超过12,代码内部会取余`deltaBetweenMaxAndMin%12`
                pickerView.minimumDate = [NSDate date];
                pickerView.deltaBetweenMaxAndMin = 10;
                ///*
                 //方式2, 设置`最小日期`和`最大日期`,超过12,代码内部会取余`deltaBetweenMaxAndMin%12`
                //pickerView.minimumDate = [NSDate date];
                //pickerView.maximumDate = [NSDate dateWithTimeInterval:10 * 30 * 24 * 60 * 60 sinceDate:pickerView.minimumDate];
                 //*/
                //方式3,什么都不写,全部使用默认值,1月1号 - 12月31号,`pickerView.deltaBetweenMaxAndMin = 12`;//会根据当前模式为`MXPickerViewModeDD_DD`设置默认值12,会自动算当月最大几号,以及闰年
                break;
            }
            case MXPickerViewModeYYYY:
            case MXPickerViewModeYYYY_YYYY: {
                //创建从(今年 -(今年 + 10)的列表,如(2018年 - 2028年),方式1和方式2结果一样,推荐方式一,方式二需要算日期,麻烦
                //方式1,设置中间的时间间隔,超过12,代码内部会取余`deltaBetweenMaxAndMin%12`
                pickerView.minimumDate = [NSDate date];
                pickerView.deltaBetweenMaxAndMin = 10;
                ///*
                //方式2, 设置最大的日期
                //pickerView.minimumDate = [NSDate date];
                //pickerView.maximumDate = [NSDate dateWithTimeInterval:10 * 12 * 30 * 24 * 60 * 60 sinceDate:pickerView.minimumDate];
                //*/
                //方式3,什么都不写,全部使用默认值,1918年 - 今年,`pickerView.deltaBetweenMaxAndMin = 100`;//会根据当前模式为`MXPickerViewModeYYYY_YYYY`设置默认值100
                break;
            }
            case MXPickerViewModeYYYY_MM: // 2018年1月
            case MXPickerViewModeYYYYMM_YYYYMM: {
                //创建从(今年1月 -(今年 + 10)12月)的列表,如(2018年1月 - 2028年12月),方式1和方式2结果一样,推荐方式一,方式二需要算日期,麻烦
                //方式1,设置中间的时间间隔,超过12,代码内部会取余`deltaBetweenMaxAndMin%12`
                pickerView.minimumDate = [NSDate date];
                pickerView.deltaBetweenMaxAndMin = 10;
                ///*
                //方式2, 设置最大的日期
                //pickerView.minimumDate = [NSDate date];
                //pickerView.maximumDate = [NSDate dateWithTimeInterval:10 * 12 * 30 * 24 * 60 * 60 sinceDate:pickerView.minimumDate];
                //*/
                //方式3,什么都不写,全部使用默认值,1918年1月 - 今年12月,`pickerView.deltaBetweenMaxAndMin = 100`;//会根据当前模式为`MXPickerViewModeYYYY_YYYY`设置默认值100
                break;
            }
            case MXPickerViewModeYYYYMMDD_YYYYMMDD: {
                //pickerView.componentWidth = 70;//6列需要在block中单独设置每一列的宽度,要不然2018显示20..
                //创建从(今年1月1号 -(今年 + 10)12月31号)的列表,如(2018年1月1号 - 2028年12月31号),方式1和方式2结果一样,推荐方式一,方式二需要算日期,麻烦
                //方式1,设置中间的时间间隔,超过12,代码内部会取余`deltaBetweenMaxAndMin%12`
                pickerView.minimumDate = [NSDate date];
                pickerView.deltaBetweenMaxAndMin = 10;
                ///*
                //方式2, 设置最大的日期
                //pickerView.minimumDate = [NSDate date];
                //pickerView.maximumDate = [NSDate dateWithTimeInterval:10 * 12 * 30 * 24 * 60 * 60 sinceDate:pickerView.minimumDate];
                //*/
                //方式3,什么都不写,全部使用默认值,1918年1月1号 - 今年12月31号,`pickerView.deltaBetweenMaxAndMin = 100`;//会根据当前模式为`MXPickerViewModeYYYY_YYYY`设置默认值100
                break;
            }
            default:
                break;
        }
        //pickerView.showsDescending = YES;//默认升序,结果为12, 1, 2, 3... 11, 12,当为降序,12, 11, 10,...4, 3, 2, 1, 12
        
        //pickerView.componentRowHeight = 100; //默认每一列`component`行高都为40,当所有的`component`行高相等时,可统一设置, 相当于`tableView.rowHeight`
        //需要为不同`component`返回不一样行高时,打开注释
        /*pickerView.configPickerViewRowHeightForComponentBlock = ^CGFloat(MXPickerView *mxPickerView, UIPickerView *pickerView, NSInteger component) {
            return 100;
        };*/
        
        //pickerView.componentWidth = 100; //默认每一列`component`列宽都为`pickerView.bounds.size.width/numberOfComponents`,当所有的`component`行高相等时,可统一设置
        //需要为不同`component`返回不一样列宽时,打开注释
        if (mode == MXPickerViewModeYYYYMMDD_YYYYMMDD) {
            pickerView.configPickerViewWidthForComponentBlock = ^CGFloat(MXPickerView *mxPickerView, UIPickerView *pickerView, NSInteger component) {
                return (component == 0 || component == 3) ? 60 : (mxPickerView.bounds.size.width - 2 * 60 - 15)/4;
            };
        }

        //pickerView.toolBarPositionBottom = YES; //默认为`NO`,`返回`和`确定`按钮显示在顶部,当设为`YES`,`返回`和`确定`按钮显示在底部
        //pickerView.topTipBarTitles = @[@"开始日期", @"结束日期"]; //不为`nil`时,`toolBarPositionBottom`会自动设置为`YES`,底部显示`返回`和`确定`按钮,顶部显示`开始日期 - 结束日期`
        //pickerView.topTipBarH = 50; //`topTipBarTitles`一栏高度,默认是44
        //pickerView.toolBarH = 30; //`返回`和`确定`按钮一栏高度,默认是44
        //pickerView.backgroundColor = [UIColor lightGrayColor];
        /*
         // 想设置`contentLabel`的各个属性,实现`appearance block`
         pickerView.configPickerViewContentLabelAppearanceForRowForComponentBlock = ^(MXPickerView *mxPickerView, UIPickerView *pickerView, UILabel *contentLabel, NSInteger row, NSInteger component) {
             contentLabel.backgroundColor = [UIColor yellowColor];
             contentLabel.textAlignment = NSTextAlignmentRight;
         };*/
        pickerView.yearLocale = @"年";
        pickerView.monthLocale = @"月";
        pickerView.dayLocale = @"号";
        pickerView.selectedTitleOrCustomModels = (NSString *)self.selectedTitleOrCustomModelsDictM[@(mode)];;
        pickerView.doneButtonDidClickBlock = ^(MXPickerViewMode pickerViewMode, CGFloat countDownDuration, NSDate *date, id selectedTitleOrCustomModels) {
            NSLog(@"selectedTitleOrCustomModels: %@", selectedTitleOrCustomModels);
            self.selectedTitleOrCustomModelsDictM[@(pickerViewMode)] = (NSString *)selectedTitleOrCustomModels;
        };
    }];

Date and time

MXPickerViewModeTime
MXPickerViewModeDate
MXPickerViewModeDateAndTime
MXPickerViewModeCountDownTimer

    [MXPickerView showWithSize:CGSizeMake(self.view.bounds.size.width, 200) pickerViewMode:mode updateBlock:^(MXPickerView *pickerView, MXPickerViewMode pickerViewMode, id uiDatePickerOrUIPickerView) {
        UIDatePicker *datePicker = (UIDatePicker *)uiDatePickerOrUIPickerView;
        datePicker.minuteInterval = 1;
        switch (mode) {
            case MXPickerViewModeTime: {
                //前1小时 - 后1小时
                datePicker.date = [NSDate date];
                datePicker.minimumDate = [NSDate dateWithTimeInterval:-1 * 60 * 60 sinceDate:datePicker.date];
                datePicker.maximumDate = [NSDate dateWithTimeInterval:1 * 60 * 60 sinceDate:datePicker.date];
                break;
            }
            case MXPickerViewModeDate:
            case MXPickerViewModeDateAndTime: {
                //前天 - 后天
                datePicker.date = [NSDate date];
                datePicker.minimumDate = [NSDate dateWithTimeInterval:-24 * 60 * 60 sinceDate:datePicker.date];
                datePicker.maximumDate = [NSDate dateWithTimeInterval:24 * 60 * 60 sinceDate:datePicker.date];
                break;
            }
            case MXPickerViewModeCountDownTimer: {
                datePicker.countDownDuration = 60 * 10;//选中为10分钟
                break;
            }
            default:
                break;
        }
        //pickerView.toolBarPositionBottom = YES; //默认为`NO`,`返回`和`确定`按钮显示在顶部,当设为`YES`,`返回`和`确定`按钮显示在底部
        //pickerView.topTipBarTitles = @[@"开始日期", @"结束日期"]; //不为`nil`时,`toolBarPositionBottom`会自动设置为`YES`,底部显示`返回`和`确定`按钮,顶部显示`开始日期 - 结束日期`
        //pickerView.topTipBarH = 50; //`topTipBarTitles`一栏高度,默认是44
        //pickerView.toolBarH = 30; //`返回`和`确定`按钮一栏高度,默认是44
        //pickerView.backgroundColor = [UIColor lightGrayColor];
        pickerView.doneButtonDidClickBlock = ^(MXPickerViewMode pickerViewMode, CGFloat countDownDuration, NSDate *date, id selectedTitleOrCustomModels) {
            NSLog(@"date: %@", date);
        };
    }];
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 205,033评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,725评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,473评论 0 338
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,846评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,848评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,691评论 1 282
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,053评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,700评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 42,856评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,676评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,787评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,430评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,034评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,990评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,218评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,174评论 2 352
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,526评论 2 343

推荐阅读更多精彩内容