zoukankan      html  css  js  c++  java
  • 组件_ UIToolbar

    组件_ UIToolbar

     /**
    1. 顶部toolbar

        2. TextField可以以UIBarButtonItem的自定义视图的方式加入toolbar

        3. 三个按钮

        4. 将UIBarButtonItem加入toolBar

        **/

       UIToolbar *toolBar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];

       [self.view addSubview:toolBar];

        UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(10, 6, 200, 32)];

       [textField setBorderStyle:UITextBorderStyleRoundedRect];// 设置边框

       [textField setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];// 设置垂直对齐

       [textField setClearButtonMode:UITextFieldViewModeWhileEditing];// 设置清除按钮

       [textField setDelegate:self];
       UIBarButtonItem *addressItem = [[UIBarButtonItem alloc]initWithCustomView:textField];
        
    //初始化UIBarButtonItem方法1
    UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRewind target:self action:@selector(todo1)];
    //初始化UIBarButtonItem方法2
    UIBarButtonItem *item1 = [[UIBarButtonItem alloc]initWithTitle:@"buttonName " style:UIBarButtonItemStyleBordered target:self action:@selector(btClick)];   
    [toolBar setItems:@[addressItem, item1, item2, item3]];
     // 设置状态栏样式,因为改变bar的时候状态栏颜色会默认变成和bar一样的颜色
       [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;

    组件_UISearchBar

    //初始化

     
       UISearchBar *search = [[UISearchBar alloc] init];
       search.autoresizingMask = UIViewAutoresizingFlexibleWidth;//可以伸缩的宽度

       search.frame = CGRectMake(0, 0, self.view.frame.size.width, kSearchH);

       search.delegate = self;

       [self.view addSubview:search];

       _searchBar = search;
    //代理方法

    #pragma mark 监听搜索框的文字改变

    - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText

    #pragma mark 搜索框开始编辑(开始聚焦)

    - (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
  • 相关阅读:
    JAVA WEB开发环境与搭建
    计科院静态网页
    Python操作MySQL数据库的三种方法
    Appium环境搭建
    webstorm 默认代码格式化更改,webstorm设置prettier规则
    appium自动化环境搭建
    从事算法设计应当熟悉的资源
    redhat6如何配置本地yum源
    Windows命令查看活动连接及根据PID查看运行程序的路径、程序名等
    Tomcat与JavaWeb技术详解
  • 原文地址:https://www.cnblogs.com/wsn1993/p/5058266.html
Copyright © 2011-2022 走看看