zoukankan      html  css  js  c++  java
  • iOS开发UI篇—Date Picker和UITool Bar控件简单介绍

    iOS开发UI篇—Date Picker和UITool Bar控件简单介绍
    一、Date Picker控件
    1.简单介绍:
    Date Picker显示时间的控件
    有默认宽高,不用设置数据源和代理
    如何改成中文的?
    (1)查看当前系统是否为中文的,把模拟器改成是中文的
    (2)属性,locale选择地区
    如果默认显示不符合需求。时间有四种模式可以设置,在model中进行设置
    时间可以自定义(custom)。
    设置最小时间和最大时间,超过就会自动回到最小时间。
    最大的用途在于自定义键盘:弹出一个日期选择器出来,示例代码如下:
     
     2.示例代码
    复制代码

    //
    // YYViewController.m
    // datepicker
    //
    // Created by apple on 14-6-3.
    // Copyright (c) 2014年 itcase. All rights reserved.
    //

    #import "YYViewController.h"

    @interface YYViewController ()
    /**
    * 文本输入框
    */
    @property (strong, nonatomic) IBOutlet UITextField *textfield;

    @end

    @implementation YYViewController

    - (void)viewDidLoad
    {
    [super viewDidLoad];
    //1
    //添加一个时间选择器
    UIDatePicker *date=[[UIDatePicker alloc]init];
    /**
    * 设置只显示中文
    */
    [date setLocale:[NSLocale localeWithLocaleIdentifier:@"zh-CN"]];
    /**
    * 设置只显示日期
    */
    date.datePickerMode=UIDatePickerModeDate;
    // [self.view addSubview:date];

    //当光标移动到文本框的时候,召唤时间选择器
    self.textfield.inputView=date;

    //2
    //创建工具条
    UIToolbar *toolbar=[[UIToolbar alloc]init];
    //设置工具条的颜色
    toolbar.barTintColor=[UIColor brownColor];
    //设置工具条的frame
    toolbar.frame=CGRectMake(0, 0, 320, 44);

    //给工具条添加按钮
    UIBarButtonItem *item0=[[UIBarButtonItem alloc]initWithTitle:@"上一个" style:UIBarButtonItemStylePlain target:self action:@selector(click) ];

    UIBarButtonItem *item1=[[UIBarButtonItem alloc]initWithTitle:@"下一个" style:UIBarButtonItemStylePlain target:self action:@selector(click)];

    UIBarButtonItem *item2=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
    UIBarButtonItem *item3=[[UIBarButtonItem alloc]initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(click)];

    toolbar.items = @[item0, item1, item2, item3];
    //设置文本输入框键盘的辅助视图
    self.textfield.inputAccessoryView=toolbar;
    }
    -(void)click
    {
    NSLog(@"toolbar");
    }
    @end

    复制代码

    实现效果:

    二、UITool Bar
    在上面可以添加子控件TOOLBAR中只能添加UIBarButtonItem子控件,其他子控件会被包装秤这种类型的
    上面的控件依次排放(空格————)
    有样式,可以指定样式(可拉伸的),一般用来做工具栏。
     
    使用toolbar做点菜的头部标题
    如何让点菜系统居中?在ios6中是正的,在ios7中是歪的
    在自定义键盘上加上一个工具栏。
    数组里什么顺序放的,就按照什么顺序显示
     
     
     
  • 相关阅读:
    linux 配置Apache 、PHP
    SQL Server DML(SELECT)常见用法(二)
    SQL Server DML(UPDATE、INSERT、DELETE)常见用法(一)
    PropertyGrid—添加EventTab
    PropertyGrid—添加属性Tab
    PropertyGrid—默认属性,默认事件,属性默认值
    PropertyGrid—为复杂属性提供下拉式编辑框和弹出式编辑框
    PropertyGrid--为复杂属性提供编辑功能
    PropertyGrid--基本功能
    Intellij IDEA使用(一)项目模板类型
  • 原文地址:https://www.cnblogs.com/LifeTechnologySupporter/p/9691146.html
Copyright © 2011-2022 走看看