iOS Development UI Chapter-date Picker and Uitool bar controls Brief Introduction

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.