项目介绍:
DatePicker
日期选择器,日期时间选择,时间选择器,年月日时分
GitHub: https://github.com/Zws-China/DatePicker
PhotoShoot
可设置属性
可设置的属性
//确定按钮颜色
@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;
弹框的类型
typedef enum{
DateStyleShowYearMonthDayHourMinute = 0, //年-月-日-时-分
DateStyleShowMonthDayHourMinute, //月-日-时-分
DateStyleShowYearMonthDay, //年-月-日
DateStyleShowMonthDay, //月-日
DateStyleShowHourMinute //时-分
}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 redColor];//年-月-日-时-分 颜色
datepicker.datePickerColor = [UIColor blackColor];//滚轮日期颜色
datepicker.doneButtonColor = [UIColor orangeColor];//确定按钮的颜色
[datepicker show];
类型2(DateStyleShowMonthDayHourMinute)
WSDatePickerView *datepicker = [[WSDatePickerView alloc] initWithDateStyle:DateStyleShowMonthDayHourMinute CompleteBlock:^(NSDate *selectDate) {
NSString *date = [selectDate stringWithFormat:@"MM-dd HH:mm"];
NSLog(@"选择的月日时分:%@",date);
}];
[datepicker show];
类型3(DateStyleShowYearMonthDay)
WSDatePickerView *datepicker = [[WSDatePickerView alloc] initWithDateStyle:DateStyleShowYearMonthDay CompleteBlock:^(NSDate *selectDate) {
NSString *date = [selectDate stringWithFormat:@"yyyy-MM-dd"];
NSLog(@"选择的年月日:%@",date);
}];
[datepicker show];
类型4(DateStyleShowMonthDay)
WSDatePickerView *datepicker = [[WSDatePickerView alloc] initWithDateStyle:DateStyleShowMonthDay CompleteBlock:^(NSDate *selectDate) {
NSString *date = [selectDate stringWithFormat:@"MM-dd"];
NSLog(@"选择的月日:%@",date);
}];
[datepicker show];
类型5(DateStyleShowHourMinute)
WSDatePickerView *datepicker = [[WSDatePickerView alloc] initWithDateStyle:DateStyleShowHourMinute CompleteBlock:^(NSDate *selectDate) {
NSString *date = [selectDate stringWithFormat:@"HH:mm"];
NSLog(@"选择的时分:%@",date);
}];
[datepicker show];