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

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐