在navigationBar上添加searchBar 并设置字体
来源:互联网 发布:网络三国游戏 编辑:程序博客网 时间:2024/05/22 15:30
//添加搜索框- (void)addSearchBar{ CGRect mainViewBounds = self.navigationController.view.bounds; self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(CGRectGetWidth(mainViewBounds)/2-((CGRectGetWidth(mainViewBounds)-120)/2), CGRectGetMinY(mainViewBounds)+27, CGRectGetWidth(mainViewBounds)-100, 30)]; _searchBar.delegate = self; _searchBar.showsCancelButton = NO; _searchBar.searchBarStyle = UISearchBarStyleMinimal; _searchBar.returnKeyType=UIReturnKeySearch; _searchBar.placeholder = @"编号/申请人/所在部门"; //修改placeholder 字体 UITextField * searchField = [_searchBar valueForKey:@"_searchField"]; [searchField setValue:kSubTextColor forKeyPath:@"_placeholderLabel.textColor"]; [searchField setValue:[UIFont boldSystemFontOfSize:13] forKeyPath:@"_placeholderLabel.font"];}
注意:在跳转页面的时候必须移除掉,否则,会在下个页面继续显示,在页面出现时再添加上
- (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; //添加搜索框 [self.navigationController.view addSubview: _searchBar];}- (void)viewWillDisappear:(BOOL)animated{ [_searchBar resignFirstResponder]; [_searchBar removeFromSuperview];}
从页面显示上来看,searchBar添加在了searchBar 上,实际上添加在了当前页的View上。
阅读全文
0 0
- 在navigationBar上添加searchBar 并设置字体
- 在tableview上添加searchbar
- 设置SearchBar文字字体
- 设置navigationbar上得字体和颜色
- navigationBar 标题字体颜色设置
- searchbar隐藏navigationbar问题解决
- Swift实用技术系列-如何在navigationbar上添加UISearchBar
- Android中添加并设置文字字体
- view添加到NavigationBar上
- 在html中向table中动态添加内容,并设置cell字体颜色
- CRichedit在结尾添加一行,同时设置字体,大小及颜色,并在添加后自动滚屏到末行,
- iOS 11 SearchBar in NavigationBar
- iOS 自定义navigationBar上得字体属性
- ios设置navigationbar.title字体的方法
- navigationbar颜色和字体颜色的设置
- swift3 设置navigationBar的字体颜色
- 设置那navigationbar title 的字体
- 一个textview里设置多种字体颜色,并添加图片
- 优秀WordPress版微信小程序推荐(二)
- tesseract 编译 vs2013 完整dll x86 64
- split(".")无效,length为0,加贴一个VersionName比较更新
- spring boot 使用jrebel配置热部署
- U8 提示功能互斥
- 在navigationBar上添加searchBar 并设置字体
- 无题
- js自执行函数
- python conda
- 稀疏表示step by step
- 【蓝桥杯】【手机尾号评分】
- 后台数据结合百度echarts生成各类图表
- CodeForces
- 微信端中的企业号、订阅号、服务号之前的区别