iOS Development UI Chapter-date Picker and Uitool Bar controls Brief Introduction
A. Date Picker control1. Brief Introduction: Date picker display time of the control has the default width high, do not set the data source and agent how to change to Chinese? (1) Check whether the current system is in Chinese, change the simulator to be Chinese (2) attribute, locale Select Region if the default display does not meet the requirements. There are four modes of time that can be set, and the setup time in model 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//2//YYVIEWCONTROLLER.M 3//DatePicker 4//5//Created by Apple on 14-6-3. 6//Copyright (c) 2014 itcase. All rights reserved. 7//8 9 #import "YYViewController.h" @interface Yyviewcontroller () 12/**13 * Text input box */15 @property (Strong, no natomic) Iboutlet Uitextfield *textfield;16 @end18 @implementation YYViewController20-(void) ViewDidLoad22 {23 [Super Viewdidload];24//125//Add a time selector for Uidatepicker *date=[[uidatepicker alloc]init];27/**28 * Settings only display Chinese */30 [date setlocale:[nslocale localewithlocaleidentifier:@ "ZH-CN"]];31/**32 * Settings only display date 33 */34 date.datepickermode=uidatepickermodedate;35//[Self.view addsubview:date];36 37//When the cursor is moved to a text box, call Call time Selector self.textfield.inputview=date;39 40//241//Create tool strip Uitoolbar *toolbar=[[uitoolbar Alloc]init ];43//Set toolbar color Toolbar.bartintcolor=[uicolor browncolor];45//Set toolbar Frame46 toolbar.frame=cgrectmake (0, 0,320, 44); 47 48//Add button to toolbar Uibarbuttonitem *item0=[[uibarbuttonitem alloc]initwithtitle:@ "Previous" Style:uiba Rbuttonitemstyleplain target:self Action: @selector (click)];50 uibarbuttonitem *item1=[[uibarbuttonitem All oc]initwithtitle:@ "Next" Style:uibarbuttonitemstyleplain target:self Action: @selector (click)];52 Uibarbutton Item *item2=[[uibarbuttonitem Alloc]initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace Target:nil action:nil];54 uibarbuttonitem *item3=[[uibarbuttonitem alloc]initwithtitle:@ "Done" Style:uibarbuttonitemstyleplain Target:self Action: @selector (click)];55 toolbar.items = @[item0, Item1, item2, item3];57//Set auxiliary view for text input box Keyboard 5 8 self.textfield.inputaccessoryview=toolbar;59}60-(void) click61 {NSLog (@ "toolbar");}64 @end
Implementation results:
Second, Uitool BarYou can add child controls above toolbar only Uibarbuttonitem child controls are added, and other child controls are wrapped scales the above controls of this type are then emitted (spaces ————) with styles, which can be specified as styles (stretchable) and are generally used as toolbars. How to make a la carte system centered by using toolbar for the head title? It is positive in IOS6 and is crooked in iOS7. 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]; Sets the text input box Keyboard auxiliary view Self.textfield.inputaccessoryview=toolbar;
iOS Development UI Chapter-date Picker and Uitool bar controls Brief Introduction