zoukankan      html  css  js  c++  java
  • IOS DatePicker 和 UIBarButtonItem 常用属性

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        //
        // self.inputTextField.inputView = [[UISwitch alloc ] init];
        
        // 1.创建时间选择器
        UIDatePicker *datePicker = [[UIDatePicker alloc] init];
        // 设置只显示日期
        datePicker.datePickerMode = UIDatePickerModeDate;
        // 设置日期为中文
        datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];
        
        self.inputTextField.inputView = datePicker;
    
    // 2.创建工具条
        UIToolbar *toolbar = [[UIToolbar alloc] init];
        toolbar.barTintColor = [UIColor purpleColor];
        toolbar.frame = CGRectMake(0, 0, 320, 44);
    
        // 2.1给工具条添加按钮
        UIBarButtonItem *item0 = [[UIBarButtonItem alloc] initWithTitle:@"上一个" style:UIBarButtonItemStylePlain target:self action:@selector(previousBtnClick)];
        
        UIBarButtonItem *item3 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
        
        UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithTitle:@"下一个" style:UIBarButtonItemStylePlain target:self action:@selector(previousBtnClick)];
        UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(previousBtnClick)];
        toolbar.items = @[item0, item1, item3, item2];
        
        // 设置文本输入框键盘的辅助视图
        self.inputTextField.inputAccessoryView= toolbar;
       
        
        /*
        // 1.创建最外面的大view
        UIView *view = [[UIView alloc] init];
        view.backgroundColor = [UIColor redColor];
        view.frame = CGRectMake(0, 480 - 162 - 44, 320, 162 + 44);
        
        // 2.创建工具条
        UIToolbar *toolbar = [[UIToolbar alloc] init];
        toolbar.barTintColor = [UIColor purpleColor];
        toolbar.frame = CGRectMake(0, 0, 320, 44);
        [view addSubview:toolbar];
        
        // 2.1给工具条添加按钮
        UIBarButtonItem *item0 = [[UIBarButtonItem alloc] initWithTitle:@"上一个" style:UIBarButtonItemStylePlain target:self action:@selector(previousBtnClick)];
        
        UIBarButtonItem *item3 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
        
         UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithTitle:@"下一个" style:UIBarButtonItemStylePlain target:self action:@selector(previousBtnClick)];
         UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(previousBtnClick)];
        toolbar.items = @[item0, item1, item3, item2];
        
        // 3.创建时间选择器
        // 1.创建时间选择器
        UIDatePicker *datePicker = [[UIDatePicker alloc] init];
        // 设置只显示日期
        datePicker.datePickerMode = UIDatePickerModeDate;
        // 设置日期为中文
        datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];
        datePicker.frame = CGRectMake(0, 44, 320, 162);
        [view addSubview:datePicker];
        
        // 4.设置文本输入框的自定义键盘为大view
        self.inputTextField.inputView = view;
         */
  • 相关阅读:
    2018.12.30【NOIP提高组】模拟赛C组总结
    【NOIP2007提高组】矩阵取数游戏
    【NOIP2007提高组】字符串的展开
    【NOIP2007提高组】统计数字
    2018.12.22【NOIP提高组】模拟B组总结
    【NOIP2013模拟11.5A组】cza的蛋糕(cake)
    CDQ分治总结
    O(2),O(3),Ofast 手动开[吸氧]
    【NOIP2013模拟11.6A组】灵能矩阵(pylon)
    【GDKOI2012模拟02.01】数字
  • 原文地址:https://www.cnblogs.com/liuwj/p/6502912.html
Copyright © 2011-2022 走看看