Giter Site home page Giter Site logo

pelelee / pgdatepicker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xiaozhuxiong121/pgdatepicker

0.0 1.0 0.0 5.25 MB

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

License: MIT License

Ruby 0.37% Objective-C 95.70% Swift 3.93%

pgdatepicker's Introduction

PGDatePicker

日期选择器,支持年、年月、年月日、年月日时、年月日时分、年月日时分秒、月日、月日时、月日时分、月日时分秒、时分、时分秒、分秒、月日周 时分等,内置了3种样式。

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

PGDatePicker CocoaPods compatible

直接看如何使用:Wiki

样式1

year

样式2

year

样式3

year

只显示中间的文字,设置isHiddenMiddleTextfalse即可,默认是true

年份

year

年月

year

年月日

year

年月日时

year

年月日时分

year

年月日时分秒

year

月日

year

月日时

year

月日时分

year

月日时分秒

year

时分

year

时分秒

year

分秒

year

月日周 时分

year

其他样式

屏幕快照1

其他样式

屏幕快照2

设置自己的样式

如果内置的样式都满足不了你的需要,想自己设置样式,也是完全支持的,可以将PGDatePicker创建出来添加到你的View上。

PGDatePicker *datePicker = [[PGDatePicker alloc]init];
[self.view addSubview:datePicker];

PGDatePickManager类就是一个典型的例子,你可以下载源码查看PGDatePickManager的简单实现,或许对你自己封装会有所帮助。

Swift使用

查看使用文档

CocoaPods安装

pod 'PGDatePicker'

1.5.1版本中对iPhone X进行了适配

使用

引入头文件

#import <PGDatePick/PGDatePickManager.h>
PGDatePickManager *datePickManager = [[PGDatePickManager alloc]init];
PGDatePicker *datePicker = datePickManager.datePicker;
datePicker.delegate = self;
[self presentViewController:datePickManager animated:false completion:nil];

#pragma PGDatePickerDelegate
- (void)datePicker:(PGDatePicker *)datePicker didSelectDate:(NSDateComponents *)dateComponents {
NSLog(@"dateComponents = %@", dateComponents);
}

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

语言跟着手机系统语言走,默认有英文,中文,繁体中文,如果是模拟器的话,将模拟器的系统语言改成中文即显示中文

设置样式

PGDatePickManager *datePickManager = [[PGDatePickManager alloc]init];
PGDatePicker *datePicker = datePickManager.datePicker;
datePicker.delegate = self;
datePicker.datePickerMode = PGDatePickerModeDate;
[self presentViewController:datePickManager animated:false completion:nil];

datePickManager.titleLabel.text = @"PGDatePicker";
//设置半透明的背景颜色
datePickManager.isShadeBackgroud = true;
//设置头部的背景颜色
datePickManager.headerViewBackgroundColor = [UIColor orangeColor];
//设置线条的颜色
datePicker.lineBackgroundColor = [UIColor redColor];
//设置选中行的字体颜色
datePicker.textColorOfSelectedRow = [UIColor redColor];
//设置未选中行的字体颜色
datePicker.textColorOfOtherRow = [UIColor blackColor];
//设置取消按钮的字体颜色
datePickManager.cancelButtonTextColor = [UIColor blackColor];
//设置取消按钮的字
datePickManager.cancelButtonText = @"Cancel";
//设置取消按钮的字体大小
datePickManager.cancelButtonFont = [UIFont boldSystemFontOfSize:17];

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

最新版本

CocoaPods compatible

许可证

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

pgdatepicker's People

Contributors

xiaozhuxiong121 avatar

Watchers

Pele 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.