• DatePicker使用


    // 创建时间选择器
        UIDatePicker *picker = [[UIDatePicker alloc] init];
        
        // 设置时间格式为只显示日期
        picker.datePickerMode = UIDatePickerModeDate;
        // 显示中文
        picker.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"ZH-CN"];
        
        // 设置键盘按为datePicker
        self.inputField.inputView = picker;
        
        // 创建工具条
        UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
        
        // 设置工具条背景色
        toolbar.tintColor = [UIColor orangeColor];
        
        // 创建UIbarButtonItem   
        UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithTitle:@"上一个" style:UIBarButtonItemStylePlain target:self action:@selector(previousBtn)];
        UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithTitle:@"下一个" style:UIBarButtonItemStylePlain target:self action:@selector(previousBtn)];
        UIBarButtonItem *item3 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
        UIBarButtonItem *item4 = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(previousBtn)];
        
        // 给工具条添加子控件
        toolbar.items = @[item1,item2, item3,item4];
        
        // 给文本框添加辅助视图
        self.inputField.inputAccessoryView = toolbar;

    效果图:

  • 相关阅读:
    git 获取之前某个版本
    mysql默认查询顺序
    tp5链式查询fetchSql(true)方法
    微信中关闭网页输入内容时的安全提示
    SourceTree + BeyondCompare 配置 + 使用教程
    SourceTree 免登录跳过初始设置
    git 常规发布流程
    Git常用操作命令
    手动安装phpRedisAdmin
    docker-compose快速搭建lnmp+redis服务器环境
  • 原文地址:https://www.cnblogs.com/Fc-ios/p/3920229.html
Copyright © 2020-2023  润新知