天天看點

時間選擇器,DatePickerDatePickerPhotoShoot

DatePicker

日期選擇器,日期時間選擇,時間選擇器,年月日時分

GitHub: https://github.com/Zws-China/DatePicker

PhotoShoot

時間選擇器,DatePickerDatePickerPhotoShoot

可設定屬性

宏定義
#define RGB(x,y,z) [UIColor colorWithRed:x/255.0 green:y/255.0 blue:z/255.0 alpha:1.0]


可設定的屬性
//确定按鈕顔色
@property (nonatomic,strong)UIColor *doneButtonColor;

//年-月-日-時-分 文字顔色(預設橙色)
@property (nonatomic,strong)UIColor *dateLabelColor;

//滾輪日期顔色(預設黑色)
@property (nonatomic,strong)UIColor *datePickerColor;

//限制最大時間(預設2099)datePicker大于最大日期則滾動回最大限制日期
@property (nonatomic, retain) NSDate *maxLimitDate;

//限制最小時間(預設0) datePicker小于最小日期則滾動回最小限制日期
@property (nonatomic, retain) NSDate *minLimitDate;

//大号年份字型顔色(預設灰色)想隐藏可以設定為clearColor
@property (nonatomic, retain) UIColor *yearLabelColor;

//預設滾動到目前時間
-(instancetype)initWithDateStyle:(WSDateStyle)datePickerStyle CompleteBlock:(void(^)(NSDate *))completeBlock;

//滾動到指定的的日期
-(instancetype)initWithDateStyle:(WSDateStyle)datePickerStyle scrollToDate:(NSDate *)scrollToDate CompleteBlock:(void(^)(NSDate *))completeBlock;


           

彈框的類型

typedef enum{
    DateStyleShowYearMonthDayHourMinute  = ,//年月日時分
    DateStyleShowMonthDayHourMinute,//月日時分
    DateStyleShowYearMonthDay,//年月日
    DateStyleShowYearMonth,//年月
    DateStyleShowMonthDay,//月日
    DateStyleShowHourMinute,//時分
    DateStyleShowYear,//年
    DateStyleShowMonth,//月
    DateStyleShowDayHourMinute,//日時分
}WSDateStyle;
           

類型1(DateStyleShowYearMonthDayHourMinute)

//_________________________年-月-日-時-分____________________________________________
WSDatePickerView *datepicker = [[WSDatePickerView alloc] initWithDateStyle:DateStyleShowYearMonthDayHourMinute CompleteBlock:^(NSDate *selectDate) {

    NSString *date = [selectDate stringWithFormat:@"yyyy-MM-dd HH:mm"];
    NSLog(@"選擇的日期:%@",date);
}];
datepicker.dateLabelColor = [UIColor orangeColor];//年-月-日-時-分 顔色
datepicker.datePickerColor = [UIColor blackColor];//滾輪日期顔色
datepicker.doneButtonColor = [UIColor orangeColor];//确定按鈕的顔色
[datepicker show];



//_________________________年-月-日-時-分(滾動到指定的日期)_________________________
NSDateFormatter *minDateFormater = [[NSDateFormatter alloc] init];
[minDateFormater setDateFormat:@"yyyy-MM-dd HH:mm"];
NSDate *scrollToDate = [minDateFormater dateFromString:@"2011-11-11 11:11"];

WSDatePickerView *datepicker = [[WSDatePickerView alloc] initWithDateStyle:DateStyleShowYearMonthDayHourMinute scrollToDate:scrollToDate CompleteBlock:^(NSDate *selectDate) {

    NSString *date = [selectDate stringWithFormat:@"yyyy-MM-dd HH:mm"];
    NSLog(@"選擇的日期:%@",date);
}];
datepicker.dateLabelColor = RGB(65, 188, 241);//年-月-日-時-分 顔色
datepicker.datePickerColor = [UIColor blackColor];//滾輪日期顔色
datepicker.doneButtonColor = RGB(65, 188, 241);//确定按鈕的顔色
datepicker.yearLabelColor = [UIColor clearColor];//大号年份字型顔色
[datepicker show];

           
時間選擇器,DatePickerDatePickerPhotoShoot

類型2(DateStyleShowMonthDayHourMinute)

WSDatePickerView *datepicker = [[WSDatePickerView alloc] initWithDateStyle:DateStyleShowMonthDayHourMinute CompleteBlock:^(NSDate *selectDate) {

    NSString *date = [selectDate stringWithFormat:@"MM-dd HH:mm"];
    NSLog(@"選擇的月日時分:%@",date);

}];
[datepicker show];
           
時間選擇器,DatePickerDatePickerPhotoShoot

類型3(DateStyleShowYearMonthDay)

WSDatePickerView *datepicker = [[WSDatePickerView alloc] initWithDateStyle:DateStyleShowYearMonthDay CompleteBlock:^(NSDate *selectDate) {

    NSString *date = [selectDate stringWithFormat:@"yyyy-MM-dd"];
    NSLog(@"選擇的年月日:%@",date);

}];
[datepicker show];
           
時間選擇器,DatePickerDatePickerPhotoShoot

類型4(DateStyleShowMonthDay)

WSDatePickerView *datepicker = [[WSDatePickerView alloc] initWithDateStyle:DateStyleShowMonthDay CompleteBlock:^(NSDate *selectDate) {

    NSString *date = [selectDate stringWithFormat:@"MM-dd"];
    NSLog(@"選擇的月日:%@",date);

}];
[datepicker show];
           
時間選擇器,DatePickerDatePickerPhotoShoot

類型5(DateStyleShowHourMinute)

WSDatePickerView *datepicker = [[WSDatePickerView alloc] initWithDateStyle:DateStyleShowHourMinute CompleteBlock:^(NSDate *selectDate) {

    NSString *date = [selectDate stringWithFormat:@"HH:mm"];
    NSLog(@"選擇的時分:%@",date);

}];
[datepicker show];
           
時間選擇器,DatePickerDatePickerPhotoShoot

類型6(DateStyleShowYear)

WSDatePickerView *datepicker = [[WSDatePickerView alloc] initWithDateStyle:DateStyleShowYear CompleteBlock:^(NSDate *selectDate) {

    NSString *date = [selectDate stringWithFormat:@"yyyy"];
    NSLog(@"選擇的:%@",date);

}];
[datepicker show];
           
時間選擇器,DatePickerDatePickerPhotoShoot

類型7(DateStyleShowMonth)

WSDatePickerView *datepicker = [[WSDatePickerView alloc] initWithDateStyle:DateStyleShowMonth CompleteBlock:^(NSDate *selectDate) {

    NSString *date = [selectDate stringWithFormat:@"MM"];
    NSLog(@"選擇的:%@",date);

}];
[datepicker show];
           
時間選擇器,DatePickerDatePickerPhotoShoot

類型8(DateStyleShowDayHourMinute)

WSDatePickerView *datepicker = [[WSDatePickerView alloc] initWithDateStyle:DateStyleShowDayHourMinute CompleteBlock:^(NSDate *selectDate) {

    NSString *date = [selectDate stringWithFormat:@"dd HH:mm"];
    NSLog(@"選擇的:%@",date);

}];
[datepicker show];
           
時間選擇器,DatePickerDatePickerPhotoShoot