组件_ 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

最新文章

  1. asp.net mvc 过滤器
  2. java提高篇(十七)-----异常(二)
  3. Ubuntu backlight
  4. 【BZOJ-2721】樱花 线性筛 + 数学
  5. CSS3-canvas绘制线性渐变
  6. [codevs2181]田忌赛马
  7. Mac下部署Android开发环境附加NDK
  8. codeforces 676B B. Pyramid of Glasses(模拟)
  9. 【报错】"The constructor Notification(int, CharSequence, long) is deprecated
  10. HDFS之HBase伪分布安装
  11. Neo4J图库的基础介绍(一)
  12. JVM活学活用——优化springboot
  13. Nginx开启gzip压缩解决react打包文件过大
  14. Holer实现外网访问ARM嵌入式Linux系统
  15. SVN+Axure版本管理&协同设计(一)
  16. springBoot(6)---过滤器,监听器,拦截器
  17. 在windows上搭建SSH服务踩过的坑
  18. rabbitmq - java client lib一二事
  19. JSP+MySQL中文乱码
  20. xlsx 库 知识点

热门文章

  1. 25 | MySQL是怎么保证高可用的?
  2. 洛谷 P2347 砝码称重 题解
  3. 【概率论】4-7:条件期望(Conditional Expectation)
  4. ubuntu16.04源码编译安装nginx1.14.2
  5. wepy框架滑动组件使用
  6. CentOS7安装Airflow
  7. (6)打造简单OS-内存分页
  8. 爬虫之获取猫眼电影10W评论
  9. Spring Cloud Gateway(四):路由定义定位器 RouteDefinitionLocator
  10. cesium地下模式(地表透明)4