IOS Development UI article -date Picker and the Uitool Bar Controls Simple Introduction
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 @interfaceTxviewcontroller ()6 7 /**8 9 * Text input boxTen One */ A -@property (Weak, nonatomic) Iboutlet Uitextfield *textfired; - the - - @end - + - + @implementationTxviewcontroller A at - -- (void) Viewdidload - - { - in [Super Viewdidload]; - to //Add a Time selector + -Uidatepicker *data =[[Uidatepicker alloc]init]; the * $ Panax Notoginseng //set to display only Chinese - the + A[Data Setlocale:[nslocale Localewithlocaleidentifier:@"ZH-CN"]]; the + //Show only Dates - $Data.datepickermode =uidatepickermodedate; $ - - the - Wuyi //Summon Time selector when cursor moves to text box the - Wu -Self.textfired.inputView =data; About $ - - //2 Creating a tool bar - AUitoolbar *toolbar =[[Uitoolbar alloc]init]; + the - $ //set the color of the toolbar the the the theToolbar.bartintcolor =[Uicolor Redcolor]; - in the the //set the color of the toolbar About theToolbar.frame = CGRectMake (0,0, the, -); the the + - //Add a button to a toolbar the Bayi the theUibarbuttonitem *item0=[[uibarbuttonitem Alloc]initwithtitle:@"previous"style:UIBarButtonItemStylePlaintarget:self Action: @selector (Didclick)]; - -Uibarbuttonitem *item1=[[uibarbuttonitem Alloc]initwithtitle:@"Next"style:UIBarButtonItemStylePlaintarget:self Action: @selector (Didclick)]; the the //Spring the theUibarbuttonitem *item2=[[Uibarbuttonitemalloc]initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespacetarget:nil Action:nil] ; - theUibarbuttonitem *item3=[[uibarbuttonitem Alloc]initwithtitle:@"Complete"Style:uibarbuttonitemstyleplain target:self Action: @selector (Didclick)]; the theToolbar.items =@[item0,item1,item2,item3];94 the the the //set the secondary view of the text input box keyboard98 Aboutself.textfired.inputaccessoryview=toolbar; - 101 }102 103-(void) Didclick104 the {106 107NSLog (@"FJLSD");108 109 the 111 } the 113- (void) didreceivememorywarning the the { the 117 [Super didreceivememorywarning];118 119 //Dispose of any of the resources that can berecreated. - 121 }122 123 124 the @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