在输入价格的时候,要求弹出的键盘只能有数字和小数点。弹出的键盘没有完成键,想要退出键盘可以点击退出,但是为了更好的用户体验,在键盘上增加UIToolbar。

设置ToolBar:

- (UIToolbar *)addToolbar {

   UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(, , CGRectGetWidth(self.view.frame), )];
toolbar.tintColor = [UIColor blackColor];
toolbar.backgroundColor = [UIColor lightGrayColor];
UIBarButtonItem *prevItem = [[UIBarButtonItem alloc] initWithTitle:@" < " style:UIBarButtonItemStylePlain target:self action:@selector(prevTextField:)];
UIBarButtonItem *nextItem = [[UIBarButtonItem alloc] initWithTitle:@" > " style:UIBarButtonItemStylePlain target:self action:@selector(nextTextField:)];
UIBarButtonItem *flbSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *doneItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"完成",nil) style:UIBarButtonItemStylePlain target:self action:@selector(textFieldDone)];
toolbar.items = @[prevItem,nextItem,flbSpace, doneItem];
return toolbar;
}

为textField添加ToolBar:

_textField.inputAccessoryView = [self addToolbar];

实现效果图:

最新文章

  1. Bzoj4008 [HNOI2015]亚瑟王
  2. Android——数据的存储和访问
  3. BeagleBone Black项目实训手册(大学霸内部资料)
  4. 进程创建函数fork()、vfork() ,以及excel()函数
  5. Android高清巨图加载方案
  6. [问题解决] 启动mongod 时,出现addr already in use错误
  7. 随机获取部分List&lt;Object&gt;集合
  8. WPF之DataContext(转)
  9. [Swift]LeetCode668. 乘法表中第k小的数 | Kth Smallest Number in Multiplication Table
  10. Linux的内存机制(转载)
  11. [转] Understanding Convolutional Neural Networks for NLP
  12. boost::asio实现一个echo服务器
  13. 64Bit &amp; 32Bit HashCode
  14. [Lua]table(一):打印与复制
  15. MATLAB中批量导入.mat文件(每个文件多变量)
  16. CentOS下多网卡绑定多IP段时导致只有一个会通的问题解决
  17. 第七周:Python
  18. 了解python wed 框架
  19. 【转】mxGraph教程-开发入门指南
  20. 一遍记住Java常用的八种排序算法与代码实现

热门文章

  1. 【Html基础】之&lt;h1&gt;~&lt;h6&gt; &lt;p&gt; &lt;br&gt; &lt;hr&gt;
  2. 解决 客户端连接 mysql5.7 Plugin &#39;mysql_native_plugin&#39; is not loaded错误
  3. javascript的 热点图怎么写
  4. Android Editable
  5. Ubuntu 安装 PhpMyAdmin 图文教程
  6. 【Oracle】DBMS_STATS.GATHER_TABLE_STATS详解
  7. C# winfrom界面跳转闪烁问题解决方法
  8. 实现UIView的无限旋转动画(非CALayer动画)
  9. 企业级Nginx增加日志选项
  10. js的一道经典题目