码迷,mamicode.com
首页 > 其他好文 > 详细

textLabel辅助试图及toolBar创建使用

时间:2015-04-18 06:22:53      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:

 1 - (void)viewDidLoad
 2 {
 3     [super viewDidLoad];
 4     //
 5     // self.inputTextField.inputView = [[UISwitch alloc ] init];
 6     
 7     // 1.创建时间选择器
 8     UIDatePicker *datePicker = [[UIDatePicker alloc] init];
 9     // 设置只显示日期
10     datePicker.datePickerMode = UIDatePickerModeDate;
11     // 设置日期为中文
12     datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];
13     
14     self.inputTextField.inputView = datePicker;
15 }
16 
17 
18 @end
19 t:) forControlEvents:UIControlEventValueChanged];
20     self.inputTextField.inputView = datePicker;
21     
22     
23     // 2.创建工具条
24     UIToolbar *toolbar = [[UIToolbar alloc] init];
25     toolbar.barTintColor = [UIColor purpleColor];
26     toolbar.frame = CGRectMake(0, 0, 320, 44);
27 
28     // 2.1给工具条添加按钮
29     UIBarButtonItem *item0 = [[UIBarButtonItem alloc] initWithTitle:@"上一个" style:UIBarButtonItemStylePlain target:self action:@selector(previousBtnClick)];
30     
31     UIBarButtonItem *item3 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
32     
33     UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithTitle:@"下一个" style:UIBarButtonItemStylePlain target:self action:@selector(previousBtnClick)];
34     UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(previousBtnClick)];
35     toolbar.items = @[item0, item1, item3, item2];
36     
37     // 设置文本输入框键盘的辅助视图
38     self.inputTextField.inputAccessoryView= toolbar;
39    
40     
41     /*
42     // 1.创建最外面的大view
43     UIView *view = [[UIView alloc] init];
44     view.backgroundColor = [UIColor redColor];
45     view.frame = CGRectMake(0, 480 - 162 - 44, 320, 162 + 44);
46     
47     // 2.创建工具条
48     UIToolbar *toolbar = [[UIToolbar alloc] init];
49     toolbar.barTintColor = [UIColor purpleColor];
50     toolbar.frame = CGRectMake(0, 0, 320, 44);
51     [view addSubview:toolbar];
52     
53     // 2.1给工具条添加按钮
54     UIBarButtonItem *item0 = [[UIBarButtonItem alloc] initWithTitle:@"上一个" style:UIBarButtonItemStylePlain target:self action:@selector(previousBtnClick)];
55     
56     UIBarButtonItem *item3 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
57     
58      UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithTitle:@"下一个" style:UIBarButtonItemStylePlain target:self action:@selector(previousBtnClick)];
59      UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(previousBtnClick)];
60     toolbar.items = @[item0, item1, item3, item2];
61     
62     // 3.创建时间选择器
63     // 1.创建时间选择器
64     UIDatePicker *datePicker = [[UIDatePicker alloc] init];
65     // 设置只显示日期
66     datePicker.datePickerMode = UIDatePickerModeDate;
67     // 设置日期为中文
68     datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];
69     datePicker.frame = CGRectMake(0, 44, 320, 162);
70     [view addSubview:datePicker];
71     
72     // 4.设置文本输入框的自定义键盘为大view
73     self.inputTextField.inputView = view;
74      */
75     
76 }
77 
78 - (void)previousBtnClick
79 {
80     NSLog(@"上一个");
81 }
82 
83 -(void)test:(UIDatePicker *)picker
84 {
85     NSLog(@"%@", picker);
86 }
87 @end

 

textLabel辅助试图及toolBar创建使用

标签:

原文地址:http://www.cnblogs.com/liqiantu/p/4436494.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!