三行代碼實現`年月日`的彈出控件

MXPickerView

MXPickerView 是一個 對 UIPickerViewUIDatePicker的封裝, 三行代碼實現年月日的彈出控件數組

ScreenShot

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

Attributes

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

BOOL toolBarPositionBottom;

//默認爲NO,返回肯定按鈕顯示在頂部,
當設爲YES,返回肯定按鈕顯示在底部

pickerView.toolBarPositionBottom = YES;

NSArray<NSString *> *topTipBarTitles;

//不爲nil時, toolBarPositionBottom
會自動設置爲YES,底部顯示返回肯定按鈕,
頂部顯示topTipBarTitles, 如開始日期 - 結束日期

pickerView.topTipBarTitles = @[@"開始日期", @"結束日期"];

CGFloat topTipBarH, toolBarH;

pickerView.topTipBarH = 50;
pickerView.toolBarH = 30;
// 底部顯示返回肯定按鈕,頂部顯示開始日期 - 結束日期
topTipBarTitles一欄高度,默認是44;
返回肯定按鈕一欄高度,默認是44

pickerView.topTipBarTitles = @[@"開始日期", @"結束日期"];

BOOL showsDescending;

// 默認升序,結果爲12, 1, 2, 3... 11, 12,
當爲降序,結果爲12, 11, 10, ...4, 3, 2, 1, 12, 僅支持mode是日期類的,如MXPickerViewModeDD...

pickerView.showsDescending = YES;

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號"
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];


CGFloat componentWidth;
//設置每一個component的寬度,等寬,若是不設置,
默認爲pickerView.bounds.size.width/numberOfComponents

pickerView.componentWidth = 100;
//每一列component列寬都爲100

CGFloat componentRowHeight;
//設置每一個component的行高,若是不設置,默認爲40

pickerView.componentRowHeight = 100;

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;};

CGFloat(^configPickerViewRowHeightForComponentBlock)(MXPickerView *mxPickerView, UIPickerView *pickerView, NSInteger component)
//爲每一個component設置相同的行高, 等價於pickerView.componentRowHeight = xx

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

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";};

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]}];};

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;};//右對齊

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};

How to use

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); };*/
    }];
複製代碼

Other date Mode

MXPickerViewModeDDMXPickerViewModeDD_DD MXPickerViewModeMM MXPickerViewModeMM_MM MXPickerViewModeMM_DD MXPickerViewModeMMDD_MMDD MXPickerViewModeYYYY MXPickerViewModeYYYY_YYYY MXPickerViewModeYYYY_MM MXPickerViewModeYYYYMM_YYYYMM MXPickerViewModeYYYYMMDD_YYYYMMDDapp

[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);
        };
    }];
複製代碼
相關文章
相關標籤/搜索