zoukankan      html  css  js  c++  java
  • iOS--UI篇——UIToolbar的简单使用

    UIToolbar的简单使用

     1 //UINavigationController 里UINavigationBar 和 UIToolbar 是一套的.
     2 //当UIViewController视图self.view加载到KeyWindow屏幕上时navigationbar 和 toolbar也都被添加到了keywindow上,而默认情况下,toolbar 是隐藏的,是一个很灵活的工具栏,可以在需要时显示出来,这方面苹果公司已封装地很完善了,一般用来作输入栏,像微信聊天界面的底部其实就是一个toolbar.
     3 
     4 //UIToolbar的简单实用
     5 
     6    UIToolbar * topView = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 30)];
     7     [topView setBarStyle:UIBarStyleDefault];
     8     UIBarButtonItem * btnSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
     9     UIBarButtonItem * doneButton = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStyleDone target:self action:@selector(dismissKeyBoard)];
    10     NSArray * buttonsArray = [NSArray arrayWithObjects:btnSpace, doneButton, nil];
    11     [topView setItems:buttonsArray];
    12     [_titleField setInputAccessoryView:topView]; //将UIToolbar加载到 UITextField 的    setInputAccessoryView 方法中,当UITextField 输入弹出键盘时 UIToolbar 会随着键盘移动到键盘的顶部;
    感谢您的访问! 若对您有帮助或有兴趣请关注博客:http://www.cnblogs.com/Rong-Shengcom/
  • 相关阅读:
    [Python] 登录人人网2011版
    [WPF] 自定义窗体样式
    [Python] 控制台输入密码的方法
    [Python] 字符串加密解密
    [WPF] 模仿AMD LIVE! EXPLORER界面
    [Python] Visual Studio 2008 集成 IronPython 开发环境
    mysql表类型(存储引擎)
    logstash收集nginx访问日志
    linux设置开机启动脚本
    logstash安装log4j插件
  • 原文地址:https://www.cnblogs.com/Rong-Shengcom/p/5199228.html
Copyright © 2011-2022 走看看