[iOS] custom date selector

Custom a date selector, to share with you, look forward to valuable suggestions.
GitHub download address: https://github.com/huahua0809/XHDatePicker
here just to explain how to use the specific implementation, please download
code to see; if you think this is helpful to share it, please send a, thank you! ?

[iOS] custom date selector
date selector

.h file parsing

  • Select the date selector style typedef enum{DateStyleShowYearMonthDayHourMinute = 0, DateStyleShowMonthDayHourMinute, DateStyleShowYearMonthDay, DateStyleShowMonthDay, DateStyleShowHourMinute,}XHDateStyle; / / date selector style @property (nonatomic, assign) XHDateStyle datePickerStyle; DateStyleShowYearMonthDayHourMinute:
    [iOS] custom date selector
    display date time display date time
    DateStyleShowMonthDayHourMinute: display July time (year on the bottom)
    [iOS] custom date selector
    display July time Division

DateStyleShowYearMonthDay: show date

[iOS] custom date selector
display date

DateStyleShowMonthDay: Show month (year at bottom)

[iOS] custom date selector
display month

DateStyleShowHourMinute: display time

[iOS] custom date selector
display time
  • Typedef enum{DateTypeStartDate, the setting time of type DateTypeEndDate}XHDateType; / / the setting time of type @property (nonatomic, assign) XHDateType dateType; DateTypeStartDate: DateTypeEndDate:
    start time end time
  • Set the maximum and minimum time limit of @property (nonatomic, retain) NSDate *maxLimitDate; / / the maximum time limit (no default 2049) @property (nonatomic, retain) NSDate *minLimitDate; / / the minimum time limit (no default 1970)
  • The init object (completeBlock is clicked after the callback is determined, returns the start time and end time) – (instancetype) initWithCompleteBlock: (void (^) (NSDate *, NSDate *)) completeBlock;

Specific use code

XHDatePickerView *datepicker = [[XHDatePickerView alloc] initWithCompleteBlock:^ (NSDate *startDate, NSDate *endDate) {NSLog (@ /n start time:% @, end time: startDate,% @ ", endDate); self.startTimeText.text [startDate stringWithFormat:@ =" yyyy-MM-dd HH:mm "]; self.endtimeText.text stringWithFormat:@ [endDate =" yyyy-MM-dd HH:mm "];}]; datepicker.datePickerStyle = DateStyleShowYearMonthDayHourMinute; datepicker.dateType = DateTypeStartDate datepicker.minLimitDate; [NSDate date:@ =" 2017-08-11 12:22 "WithFormat:@" yyyy-MM-dd HH:mm "]; [NSDate date:@ datepicker.maxLimitDate =" 2020-12-12 12:12 "WithFormat:@" yyyy-MM-dd HH:mm "]; [datepicker show];

Up NSLog printing time and the actual time difference of 8 hours, into a string will print out the right time. (because of NSLog, the format of the time is GMT time to turn, GMT time and Beijing time difference of 8 hours)