Giter VIP home page Giter VIP logo

pgdatepicker's Introduction

PGDatePicker

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

由于使用UIPickerView的话,列表会有个弧度,所以这里用了PGPickerView

CocoaPods compatible PGDatePicker

年份

year

年月

year

年月日

year

年月日时分

year

年月日时分秒

year

时分

year

时分秒

year

月日周 时分

year

Swift的使用

查看使用文档

CocoaPods安装

pod 'PGDatePicker', '>= 1.3.0'

使用

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);
}

如果不设置minimumDatemaximumDate默认是无穷小和无穷大

设置Date

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

+ (NSDate *)setYear:(NSInteger)year;
+ (NSDate *)setYear:(NSInteger)year month:(NSInteger)month;
+ (NSDate *)setYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day;
+ (NSDate *)setYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day hour:(NSInteger)hour minute:(NSInteger)minute;
+ (NSDate *)setYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day hour:(NSInteger)hour minute:(NSInteger)minute second:(NSInteger)second;
+ (NSDate *)setHour:(NSInteger)hour minute:(NSInteger)minute;
+ (NSDate *)setHour:(NSInteger)hour minute:(NSInteger)minute second:(NSInteger)second;
+ (NSDate *)setMonth:(NSInteger)month day:(NSInteger)day hour:(NSInteger)hour minute:(NSInteger)minute;

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

设置样式

//设置线条的颜色
datePicker.lineBackgroundColor = [UIColor redColor];
//设置选中行的字体颜色
datePicker.titleColorForSelectedRow = [UIColor redColor];
//设置未选中行的字体颜色
datePicker.titleColorForOtherRow = [UIColor blackColor];

//设置取消按钮的字体颜色
datePicker.cancelButtonTextColor = [UIColor blackColor];
//设置取消按钮的字
datePicker.cancelButtonText = @"取消";
//设置取消按钮的字体大小
datePicker.cancelButtonFont = [UIFont boldSystemFontOfSize:17];

//设置确定按钮的字体颜色
datePicker.confirmButtonTextColor = [UIColor redColor];
//设置确定按钮的字
datePicker.confirmButtonText = @"确定";
//设置确定按钮的字体大小
datePicker.confirmButtonFont = [UIFont boldSystemFontOfSize:17];

许可证

PGDatePicker 使用 MIT 许可证,详情见 LICENSE 文件。

pgdatepicker's People

Contributors

xiaozhuxiong121 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.