18.自定义键盘 toolbar的barTintColor UIBarButtonItem的使用 datePick使用
来源:互联网 发布:钓鱼软件app 编辑:程序博客网 时间:2024/05/24 04:09
UIDatePicker *dateP=[[UIDatePicker alloc]init];dateP.datePickerMode=UIDatePickerModeDate;//设置语言为中文(系统语言为中文时有效)dateP.locale=[[NSLocale alloc]initWithLocaleIdentifier:@"zh_CN"];dateP.frame=CGRectMake(0, 44, 320, 162);//监听datePicker的选中[dateP addTarget:self action:@selector(test:) forControlEvents:UIControlEventValueChanged];UIToolbar *toolBar=[[UIToolbar alloc]init];toolBar.frame=CGRectMake(0, 0, 320, 44);UIBarButtonItem *item=[[UIBarButtonItem alloc]initWithTitle:@"上一个" style:UIBarButtonItemStylePlain target:self action:@selector(item1)];UIBarButtonItem *item1=[[UIBarButtonItem alloc]initWithTitle:@"下一个" style:UIBarButtonItemStylePlain target:self action:@selector(item1)];UIBarButtonItem *item2=[[UIBarButtonItem alloc]initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(item1)];//这个方法可以获得可以拉伸的UIBarButtonItemUIBarButtonItem *item3=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:@selector(item1)];//会根据数组中元素顺序进行在toobar上显示NSArray *items=@[item,item1,item3,item2];toolBar.items=items;//barTintColor设置背景更为准确toolBar.barTintColor=[UIColor redColor];//进行显示的datePickerViewself.textFiled.inputView=dateP;//辅助的toobarself.textFiled.inputAccessoryView=toolBar;//在监听方法中进行获取日期-(void)test:(UIDatePicker *)picker{ NSLog(@"%@",picker.date); NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; // HH 代表24小时 hh代表12小时 formatter.dateFormat = @"yyyy-MM-dd"; NSString *time = [formatter stringFromDate:picker.date]; self.textFiled.text=time;}
UIBarButtonItem的Bordered和Plian两种style在iOS7上没有区别可以在storyboard中设置UIBarButtonItem的identifier为Flexible Space获取拉伸的UIBarButtonItem
0 0
- 18.自定义键盘 toolbar的barTintColor UIBarButtonItem的使用 datePick使用
- tintColor和barTintColor的使用
- Toolbar的使用和自定义
- 如何使用自定义的Toolbar
- Toolbar的使用以及自定义Toolbar的方法
- Toolbar的使用和自定义Toolbar作为标题栏
- iOS学习之UINavigationController详解与使用(一)添加UIBarButtonItem 自定义ToolBar以及页面切换
- 自定义的UIBarButtonItem
- 关于UIBarButtonItem的自定义
- ToolBar控件的使用
- Toolbar的高级使用
- Android --Toolbar的使用
- ToolBar的使用
- android toolbar的使用
- ToolBar的使用
- toolbar的使用
- ToolBar的基本使用
- ToolBar的使用
- HAL code debug
- 仿新浪微博IOS客户端(v5.2.8)——下拉菜单栏的实现
- 符号三角形的回溯算法(王晓东算法分析例题)
- Android开发-----NDK开发中的一些常见错误及解决办法
- C语言的结构与联合
- 18.自定义键盘 toolbar的barTintColor UIBarButtonItem的使用 datePick使用
- C 语言状态机编程-去掉代码注释
- xUtils 中的BitmapUtils 全面注释
- sql 的性能优化
- xUtils 中的BitmapUtils 全面注释
- hdu5228 ZCC loves straight flush(模拟)
- 关于派生类构造函数与基类构造函数的调用顺序问题
- web前端框架
- linux最简单的驱动编写及测试流程