发布网友 发布时间:2022-04-27 03:40
共1个回答
热心网友 时间:2022-06-25 15:23
说白了,就是在navigationcotroller中,显示一个view,具体实现可参考如下代码CGRect mainViewBounds = self.navigationController.view.bounds; UISearchBar *customSearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(CGRectGetWidth(mainViewBounds)/2-((CGRectGetWidth(mainViewBounds)-120)/2), CGRectGetMinY(mainViewBounds)+22, CGRectGetWidth(mainViewBounds)-120, 40)]; customSearchBar.delegate = self; customSearchBar.showsCancelButton = NO; customSearchBar.searchBarStyle = UISearchBarStyleMinimal; [self.navigationController.view addSubview: customSearchBar];