小编ios*_*ios的帖子

在导航标题下添加搜索栏

这是我的代码:

[self.navigationController.navigationBar setFrame:CGRectMake(0, 0, 500, 800)];
self.navigationItem.title = @"locations";
[self.navigationController.navigationBar setFrame:CGRectMake(0, 0, self.view.frame.size.width,110.0)];
UISearchBar *searchBar1 = [[UISearchBar alloc]initWithFrame:CGRectMake(10, 40, 240, 34)];
[self.navigationController.view addSubview:searchBar1];
elf.navigationItem.title = @"locations";
//self.navigationItem.titleView = searchController.searchBar;
self.navigationController.navigationBar.barTintColor = `Color grayColor];
self.definesPresentationContext = YES;
Run Code Online (Sandbox Code Playgroud)

像那个屏幕截图

objective-c uinavigationcontroller uisearchbar ios

3
推荐指数
1
解决办法
5190
查看次数