datepicker自定义 -- iOS
/**
* 创建时间选择器
*/
- (void)createPickerView {
self.datePicker = [[UIDatePicker alloc] init];
_datePicker.backgroundColor = [UIColor whiteColor];
// 设置只显示中文
[_datePicker setLocale:[NSLocale localeWithLocaleIdentifier:@"zh-CN"]];
// 设置只显示日期
_datePicker.datePickerMode = UIDatePickerModeDate;
// 当光标移动到文本框时, 召出时间选择器
self.birthTextField.inputView = _datePicker;
// 创建工具条
UIToolbar *toolBar = [[UIToolbar alloc] init];
// 设置背景色
toolBar.barTintColor = [UIColor whiteColor];
toolBar.frame = CGRectMake(, , SCREEN_WIDTH, );
// 给工具条添加按钮
UIBarButtonItem *cancleItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(cancel)];
UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];
// 设置UIBarButtonSystemItemFixedSpace的宽度
spaceItem.width = SCREEN_WIDTH - ;
UIBarButtonItem *sureItem = [[UIBarButtonItem alloc] initWithTitle:@"确认" style:UIBarButtonItemStylePlain target:self action:@selector(sure)];
// 设置字体颜色
toolBar.tintColor = [UIColor redColor];
toolBar.items = @[cancleItem, spaceItem, sureItem];
// 设置文本输入框键盘的辅助视图
self.birthTextField.inputAccessoryView = toolBar;
}
/**
* 点击取消按钮
*
* @param datePicker
*/
- (void)cancel { }
/**
* 点击确定按钮
*
* @param datePicker
*/
- (void)sure {
NSString *date = [NSString stringWithFormat:@"%@", _datePicker.date];
NSString *birth = [date substringToIndex:];
self.birthTextField.text = birth;
[_birthTextField resignFirstResponder];
}
效果如下:

datepicker自定义 -- iOS的更多相关文章
- 自定义iOS 中推送消息 提示框
看到标题你可能会觉得奇怪 推送消息提示框不是系统自己弹出来的吗? 为什么还要自己自定义呢? 因为项目需求是这样的:最近需要做 远程推送通知 和一个客服系统 包括店铺客服和官方客服两个模块 如果有新的消 ...
- 【转】自定义iOS的Back按钮(backBarButtonItem)和pop交互手势(interactivepopgesturerecognizer) --- 不错
原文网址:http://blog.csdn.net/joonsheng/article/details/41362499 序 说到自定义UINavigetionController的返回按钮,iOS7 ...
- 如何自定义iOS中的控件
本文译自 How to build a custom control in iOS .大家要是有什么问题,可以直接在 twitter 上联系原作者,当然也可以在最后的评论中回复我. 在开发过程中,有时 ...
- VCTransitionsLibrary –自定义iOS交互式转场动画的库
简介 VCTransitionsLibrary 提供了许多适用于入栈,出栈,模态等场景下控制器切换时的转场动画.它本身提供了一个定义好的转场动画库,你可以拖到自己工程中直接使用;也提供了许多拥有不同转 ...
- 自定义iOS上双击Home键图切换
如果双击Home,会来到iOS App的switcher页面,在这儿列出了当前系统挂起的App, 上面有每个App的切屏,相信大家都熟悉这个东东了.它其实是每个App在挂起前,对App后个载屏. 那么 ...
- UIview 学习与自定义--ios
UIView *view1=[[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)]; view1.backgroundColor=[UI ...
- 对话框 自定义 IOS风格 包青天
activity private void showDialog1() { message = "您输入的邮箱后缀不是公司邮箱地址\n将导致您的借款审核不通过,请重新 ...
- 自定义ios NSLog
#ifdef DEBUG #define MyLog(FORMAT, ...) fprintf(stderr,"Time:%s\t File:%s\t Methods:%s\t Line:% ...
- 利用贝塞尔曲线绘制(UIBezierPath)自定义iOS动态速度表,可以自定义刻度,刻度值,进度条样式
GitHub的Demo下载地址 使用UIBezierPath画图步骤: 创建一个UIBezierPath对象 调用-moveToPoint:设置初始线段的起点 添加线或者曲线去定义一个或者多个子路径 ...
随机推荐
- MSDE简介
MSDE的全程是Microsoft SQL Server Desktop Engine,它是一个基于 SQL Server 核心技术构建的数据引擎.MSDE 2000 支持单处理器和双处理器,是面向小 ...
- 由fdopen和fopen想到的
ISO C并没有规定fdopen,而是POSIX的补充. FILE *fopen(const char *path, const char *mode); FILE *fdopen(int fd, c ...
- makefile中的伪目标
伪目标就是总是被执行的目标,相对于目标来说,伪目标不会去考虑它的依赖的时间戳与自己时间戳的新旧关系,从而决定是否执行规则.伪目标格式: .PHONY:clean clean: -rm *.o 在mak ...
- Linux Bash shell one practice : array if else
shell practice 1 1.require A B C D 1 2 3 4 5 6 7 8 3 5 8 0 1 2 4 3 after handling: T A B C D A 1 2 3 ...
- 06-图2 Saving James Bond - Easy Version
题目来源:http://pta.patest.cn/pta/test/18/exam/4/question/625 This time let us consider the situation in ...
- Redis安全访问
限制IP(只能一个) # If you want you can bind a single interface, if the bind option is not # specified all ...
- WIN7系统自带截图工具SnippingTool
在无网络的情况下,无QQ情况下,如何截图?以及如何设置快捷键? 方法 首先,我们在“开始”菜单最上面找到它,如图: 找不到也没关系 C:\Windows\system32\SnippingTool.e ...
- Cursor的各种效果
总结之后的Cursor的各种效果: http://sandbox.runjs.cn/show/bbwoyn0c http://css-cursor.techstream.org/ 源代码如下: < ...
- Linux 进程通信(共享内存区)
共享内存是由内核出于在多个进程间交换信息的目的而留出的一块内存区(段). 如果段的权限设置恰当,每个要访问该段内存的进程都可以把它映像到自己的私有地址空间中. 如果一个进程更新了段中的数据,其他进程也 ...
- C语言 复杂的栈(链表栈)
//复杂的栈--链表栈 #include<stdio.h> #include<stdlib.h> #define datatype int//定义链表栈数据类型 //定义链表栈 ...