IOS UI Basics -14.0 DatePicker

Source: Internet
Author: User

Main properties of DatePicker:

    • Mode: Displays the content, can choose the date, the time free combination
    • Locale: the displayed language style
    • Interval: Time interval for each option
    • Date: The currently selected time
    • Constraint: Specify minimum and maximum time
    • Timer: Timer

Creating DatePicker with Code

// 1. Create DatePicker    Uidatepicker *datepicker = [[Uidatepicker alloc] init];     // 2. Setting the Mode     [DatePicker setdatepickermode:uidatepickermodedate];     // 3. Set Locale    [DatePicker setlocale:[nslocale Localewithlocaleidentifier:@ "zh_cn"];     // 4. Set the TextField response keyboard to DatePicker    [Self.textfield Setinputview:datepicker];

Creating Uitoolbar with Code

//1. Create UitoolbarUitoolbar *toolbar =[[Uitoolbar alloc] init];Toolbar.bartintcolor = [Uicolor Graycolor];//This is the background color of Uitoolbar.Toolbar.frame = CGRectMake (0,0, the, -);//Size,uitoolbar must be set to display, otherwise only item can be displayed, and cannot be clicked//2. Create ItemUibarbuttonitem *item1 = [[Uibarbuttonitem alloc] Initwithtitle:@"previous"Style:uibarbuttonitemstyleplain target:self Action: @selector (previousclicked)]; Uibarbuttonitem*ITEM2 = [[Uibarbuttonitem alloc] Initwithtitle:@"Next"Style:uibarbuttonitemstyleplain target:self Action: @selector (nextclicked)]; Uibarbuttonitem*ITEM3 = [[Uibarbuttonitem alloc] Initwithtitle:@"Complete"Style:uibarbuttonitemstyleplain target:self Action: @selector (finishclicked)]; //Gap ItemUibarbuttonitem *spaceitem =[[Uibarbuttonitem alloc] Initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace target:self action:nil       ]; //3. Add Item to UitoolbarToolbar.items =@[item1, item2, Spaceitem, Item3]; //4. Add Uitoolbar to the top of the keyboard and set the secondary view to TextFieldSelf.textField.inputAccessoryView = ToolBar;

IOS UI Basics -14.0 DatePicker

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.