在导航栏添加搜索框
Posted ZHZMAREN
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在导航栏添加搜索框相关的知识,希望对你有一定的参考价值。
//导航条的搜索条
UISearchBar *searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(500.0f,0.0f,250.0f,44.0f)];
searchBar.delegate = self;
[searchBar setPlaceholder:@
"搜索"
];
//将搜索条放在一个UIView上
UIView *searchView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 768, 44)];
searchView.backgroundColor = [UIColor clearColor];
[searchView addSubview:searchBar];
self.navigationItem.titleView = searchView;
[[UINavigationBar appearance] setTitleTextAttributes:@NSForegroundColorAttributeName:[UIColor whiteColor]];
|
以上是关于在导航栏添加搜索框的主要内容,如果未能解决你的问题,请参考以下文章
如何在 bootstrap 3 导航栏中使 select2 v4 搜索框响应?