//导航条的搜索条
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]}];
|
在导航栏添加搜索框
最新推荐文章于 2024-05-10 22:25:46 发布