iOS UI基础-14.0 DatePicker

DatePicker的主要属性:
- Mode:显示的内容,可以选择日期、时间的自由组合
- Locale:显示的语言样式
- Interval:每个选项的时间间隔
- Date:当前选择的时间
- Constraint:指定最小和最大时间
- Timer:计时器
使用代码创建DatePicker
// 1.创建DatePicker
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
// 2.设置模式
[datePicker setDatePickerMode:UIDatePickerModeDate];
// 3.设置locale
[datePicker setLocale:[NSLocale localeWithLocaleIdentifier:@"zh_CN"]];
// 4.设置textField的响应键盘为DatePicker
[self.textField setInputView:datePicker];
使用代码创建UIToolBar
// 1.创建UIToolBar
UIToolbar *toolBar = [[UIToolbar alloc] init];
toolBar.barTintColor = [UIColor grayColor]; // 这个才是UIToolBar的背景色
toolBar.frame = CGRectMake(, , , ); // 必须设置好size,UIToolBar才能显示,否则只能显示Item,且不能点击
// 2.创建Item
UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithTitle:@"上一个" style:UIBarButtonItemStylePlain target:self action:@selector(previousClicked)]; UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithTitle:@"下一个" style:UIBarButtonItemStylePlain target:self action:@selector(nextClicked)]; UIBarButtonItem *item3 = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(finishClicked)]; // 间隙Item
UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]; // 3.添加Item到UIToolBar
toolBar.items = @[item1, item2, spaceItem, item3]; // 4.添加UIToolBar到键盘上方,设置为textField的辅助视图
self.textField.inputAccessoryView = toolBar;
iOS UI基础-14.0 DatePicker的更多相关文章
- iOS UI基础-17.0 UILable之NSMutableAttributedString
在iOS开发中,常常会有一段文字显示不同的颜色和字体,或者给某几个文字加删除线或下划线的需求.之前在网上找了一些资料,有的是重绘UILabel的textLayer,有的是用html5实现的,都比较麻烦 ...
- iOS UI基础-9.0 UITableView基础
在iOS中,要实现表格数据展示,最常用的做法就是使用UITableView.UITableView继承自UIScrollView,因此支持垂直滚动,而且性能极佳. UITableView有两种样式: ...
- iOS UI基础-4.0应用程序管理
功能与界面 功能分析: 以九宫格的形式展示应用信息 点击下载按钮后,做出相应的操作 步骤分析: 加载应用信息 根据应用的个数创建对应的view 监听下载按钮点击 整个应用界面: 程序实现 思路 UI布 ...
- iOS UI基础-19.0 UICollectionView
直接上代码,说明请看注释吧 1.继承三个代理 UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateF ...
- iOS UI基础-16.0 UIButton
回归自然,UIButton是我们使用最频烦的一个控件.下面,对该控件的一些常用方法进行一些总结. UIButton *payStateBtn = [UIButton buttonWithType:UI ...
- iOS UI基础-15.0 UIWebView
WebView介绍 知识点: 代码创建一个UIWebView OC调用html的js js页面调用OC 相关代码实现 代码创建一个UIWebView // 1.webView UIWebView *w ...
- iOS UI基础-13.0 数据存储
应用沙盒 每个iOS应用都有自己的应用沙盒(应用沙盒就是文件系统目录),与其他文件系统隔离.应用必须待在自己的沙盒里,其他应用不能访问该沙盒 应用沙盒的文件系统目录,如下图所示(假设应用的名称叫Lay ...
- iOS UI基础-12.0 Storyboard
storyboard创建控制器 1.先加载storyboard文件(Test是storyboard的文件名) UIStoryboard *storyboard = [UIStoryboard stor ...
- iOS UI基础-10.0 QQ聊天布局之键盘及文本使用
要实现的效果: 这里只说用到的几个知识点 1.图片包含文字 在设置文字的Frame的时候,使用背景(按钮)的尺寸,文字使用了内边距 背景图片,使用拉伸 /** * 返回一张可以随意拉伸不变形的图片 ...
随机推荐
- ROS rosrun 调用 sudo 命令
https://blog.csdn.net/qq_16775293/article/details/81138904
- POJ 1816 - Wild Words - [字典树+DFS]
题目链接: http://poj.org/problem?id=1816 http://bailian.openjudge.cn/practice/1816?lang=en_US Time Limit ...
- UILabel中NSAttributedString和其LinebarkModel等属性之间的关系
如果设置了一个富文本给一个UILabel,那么后续改变这个UILabel的属性时将会同时改变UILabel.attributedText的属性描述,此时若改变了其它的大小.换行模式(如果在显示时我们可 ...
- Go所提供的面向对象功能十分简洁,但却兼具了类型检查和鸭子类型两者的有点,这是何等优秀的设计啊!
Go所提供的面向对象功能十分简洁,但却兼具了类型检查和鸭子类型两者的有点,这是何等优秀的设计啊! <代码的未来>
- HTML基础标签大全
HTML 标签大全及属性 常用的块级元素有 :div , from , table, p ,pre,h1-h5,dl,ol,ul 常用的内联元素:span ,a ,strong,em ,label , ...
- [dpdk][kni] dpdk kernel network interface
文档:https://doc.dpdk.org/guides/prog_guide/kernel_nic_interface.html 摘要: The KNI kernel loadable modu ...
- airflow 实战
def print_hello(*a,**b): print a print "=========" print b print 'Hello world!' raise Valu ...
- JS实现倒计时(天数,时,分,秒)
<!DOCTYPE html> <html> <head> <meta charset="utf-8" > <titl ...
- 【JMeter】【接口测试】csv参数化,数据驱动,自动化测试
csv参数化,数据驱动 首先我们要有一个接口测试用例存放的地方,我们这里用EXCEL模板管理,里面包含用例编号.入参.优先级.请求方式.url等等. 1:新建一个txt文件,命名为sjqd,后缀名 ...
- MySQL Sandbox安装使用
前言 经常看见新同学对于安装MySQL十分惧怕,这是因为不熟悉的缘故,确实源码编译比较麻烦,缺少各种依赖包也够折腾的.当然还有预编译包,但是对于新同学来说好像都挺麻烦的.当然有yum安装,但是我们需要 ...