9783bca8cfa60dfd798b86df2f3586eb.gif

项目介绍:

日期选择器,支持年、年月、年月日、时分、年月周 时分等。

由于使用UIPickerView的话,列表会有个弧度,所以这里用了https://github.com/xiaozhuxiong121/PGPickerView

63aecfb04f5b31ceef0b825f08236631.gif

GitHub地址

https://github.com/xiaozhuxiong121/PGDatePicker

CocoaPods安装

pod 'PGDatePicker'

使用

PGDatePicker *datePicker = [[PGDatePicker alloc]init];

datePicker.delegate = self;

[datePicker show];

datePicker.datePickerMode = PGDatePickerModeYear;

#pragma PGDatePickerDelegate

- (void)datePicker:(PGDatePicker *)datePicker didSelectDate:(NSDateComponents *)dateComponents {

NSLog(@"dateComponents = %@", dateComponents);

}

设置Date

建议用NSDate+PGCategory类所定义的方法去设置

+ (NSDate *)setYear:(NSUInteger)year;

+ (NSDate *)setYear:(NSUInteger)year month:(NSUInteger)month;

+ (NSDate *)setYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day;

+ (NSDate *)setMonth:(NSUInteger)month day:(NSUInteger)day hour:(NSInteger)hour minute:(NSInteger)minute;

+ (NSDate *)setHour:(NSInteger)hour minute:(NSInteger)minute;

比如:datePicker.maximumDate = [NSDate setYear:2017];

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐