标签:style blog http ar io color os 使用 sp
1 // 1.创建DatePicker 2 UIDatePicker *datePicker = [[UIDatePicker alloc] init]; 3 // 2.设置模式 4 [datePicker setDatePickerMode:UIDatePickerModeDate]; 5 // 3.设置locale 6 [datePicker setLocale:[NSLocale localeWithLocaleIdentifier:@"zh_CN"]]; 7 // 4.设置textField的响应键盘为DatePicker 8 [self.textField setInputView:datePicker];
1 // 1.创建UIToolBar 2 UIToolbar *toolBar = [[UIToolbar alloc] init]; 3 // toolBar.backgroundColor = [UIColor grayColor]; 4 // toolBar.tintColor = [UIColor blueColor]; 5 toolBar.barTintColor = [UIColor grayColor]; // 这个才是UIToolBar的背景色 6 toolBar.frame = CGRectMake(0, 0, 320, 44); // 必须设置好size,UIToolBar才能显示,否则只能显示Item,且不能点击 7 // 2.创建Item 8 UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithTitle:@"上一个" style:UIBarButtonItemStylePlain target:self action:@selector(previousClicked)]; 9 10 UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithTitle:@"下一个" style:UIBarButtonItemStylePlain target:self action:@selector(nextClicked)]; 11 12 UIBarButtonItem *item3 = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(finishClicked)]; 13 14 // 间隙Item 15 UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]; 16 17 // 3.添加Item到UIToolBar 18 toolBar.items = @[item1, item2, spaceItem, item3]; 19 20 // 4.添加UIToolBar到键盘上方,设置为textField的辅助视图 21 self.textField.inputAccessoryView = toolBar;
[iOS基础控件 - 6.10.3] DatePicker & UIToolBar
标签:style blog http ar io color os 使用 sp
原文地址:http://www.cnblogs.com/hellovoidworld/p/4169093.html