自定义一个只显示年月的DatePicker(UIDatePicker无法实现年月显示)
HooDatePicker 介绍(introduction)
==================================================
项目需要一个DatePicker,只显示年月,而且选中的时间高亮显示(苹果默认的只显示灰色),研究多个代码后没有达到预想效果,没办法只能动手丰衣足食,用了一天时间封装出这个性能比较高的自定义DatePicker。苹果原生的UIDatePicker无法实现只提供年月选择,而HooDatePicker增加了年月显示,并提供了扁平化和样式美化,也更加符合中国人的时间习惯。
A customized DatePicker. which can show only Years and months.the UIDatePicker don't achive this. and HooDatePicker looks much more beautiful than UIDatePicker.I hope you can like it.
Github address
==================================================
(Github下载地址):https://github.com/jakciehoo/HooDatePicker
效果图展示(picure show):
==================================================HooDatePickerModeDate Demo picture:

HooDatePickerModeYearAndMonth Demo picture

如何使用How To Use:
==================================================
HooDatePicker *datePicker = [[HooDatePicker alloc] initWithSuperView:self.view];
datePicker.delegate = self;
datePicker.datePickerMode = HooDatePickerModeYearAndMonth;
[datePicker show];
[datePicker dismiss];
更多用法More:
==================================================
1.设置其他属性
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd-MM-yyyy HH:mm:ss"];
NSDate *maxDate = [dateFormatter dateFromString:@"01-01-2050 00:00:00"];
NSDate *minDate = [dateFormatter dateFromString:@"01-01-2016 00:00:00"];
[self.datePicker setDate:[NSDate date] animated:YES];//设置默认日期
self.datePicker.minimumDate = minDate;//设置显示的最小日期
self.datePicker.maximumDate = maxDate;//设置显示的最大日期
[self.datePicker setTintColor:[UIColor redColor]];//设置主色
[self.datePicker setHighlightColor:[UIColor yellowColor]];//设置高亮颜色
2.相关代理
@protocol HooDatePickerDelegate<NSObject>
@optional
- (void)datePicker:(HooDatePicker *)datePicker dateDidChange:(NSDate *)date;
- (void)datePicker:(HooDatePicker *)datePicker clickedCancelButton:(UIButton *)sender;
- (void)datePicker:(HooDatePicker *)datePicker clickedSureButton:(UIButton *)sender date:(NSDate*)date;
@end
For more detail, you can download this project and see demo code in it.
Enjoy it!!
欢迎关注我的微信公众号“丁丁的coding日记”,一起学习iOS开发技术

自定义一个只显示年月的DatePicker(UIDatePicker无法实现年月显示)的更多相关文章
- 使用VideoView自定义一个播放器控件
介绍 最近要使用播放器做一个简单的视频播放功能,开始学习VideoView,在横竖屏切换的时候碰到了点麻烦,不过在查阅资料后总算是解决了.在写VideoView播放视频时候定义控制的代码全写在Actv ...
- 自定义View(7)官方教程:自定义View(含onMeasure),自定义一个Layout(混合组件),重写一个现有组件
Custom Components In this document The Basic Approach Fully Customized Components Compound Controls ...
- ExtJs5_继承自定义一个控件
Extjs的开发都可以遵循OOP的原则,其对类的封装也很完善了.自定义一个控件最简单的办法就是继承一个已有的控件.根据上一节的需要,我做了一个Button的子类.首先根据目录结构,在app目录下建立一 ...
- 6、手把手教你Extjs5(六)继承自定义一个控件
Extjs的开发都可以遵循OOP的原则,其对类的封装也很完善了.自定义一个控件最简单的办法就是继承一个已有的控件.根据上一节的需要,我做了一个Button的子类.首先根据目录结构,在app目录下建立一 ...
- 自定义一个更好用的SwipeRefreshLayout(弹力拉伸效果详解)(转载)
转自: 自定义一个更好用的SwipeRefreshLayout(弹力拉伸效果详解) 前言 熟悉SwipeRefreshLayout的同学一定知道,SwipeRefreshLayout是android里 ...
- jQuery Validate 表单验证插件----自定义一个验证方法
一.下载依赖包 网盘下载:https://yunpan.cn/cryvgGGAQ3DSW 访问密码 f224 二.引入依赖包 <script src="../../scripts/j ...
- JSTL,自定义一个标签的功能案例
1.自定义一个带有两个属性的标签<max>,用于计算并输出两个数的最大值: 2.自定义一个带有一个属性的标签<lxn:readFile src=“”>,用于输出指定文件的内容 ...
- 一个只需要点 「下一步」就完成监控 Windows
Cloud Insight 此前已然支持 Linux 操作系统,支持20多中数据库中间件等组件,多种操作,多种搭配,服务器监控玩的其乐无穷啊!但想想还有许多 Windows 的小伙伴没有体验过,所以在 ...
- C#特性:从自定义一个特性开始,谈谈什么是特性
作为C#新手中的一员,我刚开始接触特性时,那真是一脸冏逼啊,怎么想怎么查资料都没弄明白它到底是个什么东西,有的入门教程甚至都没讲特性和反射这些概念!相信很多人第一次接触到特性就是关于系列化的知识了. ...
随机推荐
- Oracle Deadlock / 死锁 处理
Get the directory of alert log sqlplus / as sysdba show parameters udmp SQL> show parameters dump ...
- 转!!left join on and 与 left join on where的区别
数据库在通过连接两张或多张表来返回记录时,都会生成一张中间的临时表,然后再将这张临时表返回给用户. 在使用left jion时,on和where条件的区别如下: 1. on条件是在生成临时 ...
- thinkphp发邮件失败原因
使用phpmailer出现连接失败, 代码是别人已经封装好的没有问题,可能原因有如下. qq提示: SMTP server error: mail from address must be same ...
- away3D改造白皮书
[多余的stage3D的考虑] 因为away3D为了支持stage本身可以有n个stage3D对象这个特性,在诸如MaterialPassBase.SubGeometry中,为Program3D.Ve ...
- VWmare workstation12.5中出现的问题
安装VWmare Workstation12.5之后,出现只能从主机复制文件到虚拟机,但是虚拟机的文件不能直接拖到主机中进行复制.所以我们需要重新安装VWmare Tools. 在虚拟机的VM-> ...
- url的内容及格式
url的内容及结构: url格式:
- YY前端课程2
1. alt属性对SEO优化很重要 2. 最早的网页是靠table布局标签,后来用div+css进行网页重构(因此现在网页设计的名字由网页设计变成了网页重构) 3. 静态网页和后台没有交互 动态网页和 ...
- Android-小tips
1.只保留float类型的一位小数, String.format("%.1f", float值) 2.android edittext 限制输入内容: android:d ...
- qt 编译问题总结
1)使用make命令编译Qt原码时出现了 /usr/bin/ld: cannot find -lXrender 问题: /usr/bin/ld: cannot find -lXrender ...
- 数据类型和Json格式(转载)
作者: 阮一峰 日期: 2009年5月30日 1. 前几天,我才知道有一种简化的数据交换格式,叫做yaml. 我翻了一遍它的文档,看懂的地方不多,但是有一句话令我茅塞顿开. 它说,从结构上看,所有的数 ...