First, Date Picker Control
1. Brief Introduction:
Date picker controls that display time
There is a default wide height without setting up the data source and proxy
How to change to Chinese?
(1) To see if the current system is in Chinese, change the simulator to Chinese
(2) attribute, locale Select region
If the default display does not meet the requirements. Time can be set in four modes, set in model
Time can be customized (custom).
Set the minimum and maximum time, which will automatically return to the minimum time.
The biggest use is to customize the keyboard: Pop out a date selector, the sample code is as follows:
2. Sample Code
1 #import "TXViewController.h" 2 3 4 5 @interface Txviewcontroller () 6 7/** 8 9 * Text input Box 10 11 */12 @property (Weak, nonatomic) Iboutlet Uitextfield *textfired; @end @implementation Txviewcontroller-(void) Viewdidload 26 27 {28-29) [Super Viewdidload]; 30 31//Add a time selector uidatepicker *data = [[Uidatepicker alloc]init]; 34 35 36 37//Set only display Chinese (data setlocale:[nslocale localewithlocaleidentifier:@ "ZH-CN"]; 42 43//Display date only data.datepickermode = Uidatepickermodedate; 46 47 48 49 50 51//When the cursor moves to the text box, the summon time selector is Self.textfired.inputView = data; 56 57 58 59//2 Create a toolbar Uitoolbar *toolbar = [[Uitoolbar alloc]init]; 62 63 64 65//Set the color of the tool strip Toolbar.bartintcolor = [Uicolor Redcolor]; 70 71 72 73//Set the color of the toolbar Toolbar.frame = CGRectMake (0, 0, 320, 55); 76 77 78 79//Add button to toolbar Uibarbuttonitem *item0=[[uibarbuttonitem alloc]initwithtitle:@ "prev" s Tyle:UIBarButtonItemStylePlaintarget:self Action: @selector (Didclick)]; Uibarbuttonitem *item1=[[uibarbuttonitem alloc]initwithtitle:@ "Next" Style:uibarbuttonitemstyleplaintarget: Self action: @selector (Didclick)]; 86 87//Spring Uibarbuttonitem *item2=[[uibarbuttonitemalloc]initwithbarbuttonsystemitem:uibarbuttonsystemitem Flexiblespacetarget:nil Action:nil]; Uibarbuttonitem *item3=[[uibarbuttonitem alloc]initwithtitle:@ "Done" Style:uibarbuttonitemstyleplain target:self Action: @selector (Didclick)]; Toolbar.items = @[item0,item1,item2,item3]; 94 95 96 97//Set the auxiliary view of the Text input box keyboard 98 SELF.TEXTFIRED.INPUTACCESSORYVIEW=TOOLBAR;100 101}102 103-(void) DIDCLICK104 106 107 NSLog (@ "FJLSD"), 108 109, 111}112 113-(void) didReceiveMemoryWarning114 115 {116 117 [Super didreceivememorywarning];118 119 Dispose of any resources that can berecreated.120 121}122 123 124 @end
Implementation results:
Second, Uitool Bar
You can add only Uibarbuttonitem child controls on the toolbar, and other child controls will be wrapped on the scale. This type of
The above controls are emitted in turn (space ————)
Style, you can specify the style (stretchable), which is generally used to make the toolbar.
Use toolbar to do a la carte header
How to get the ordering system centered? In the IOS6 is positive, in the iOS7 is crooked
Add a toolbar to your custom keyboard.
The order in which they are placed in the array is shown in what sequence.
Toolbar.items = @[item0,item1, item2, Item3];
Set the secondary view of the text input box keyboard
Self.textfield.inputaccessoryview=toolbar;
iOS Development UI Chapter-date Picker and Uitool bar controls Brief Introduction