导航栏出添加搜索框,应该是大多数app应用中需要使用的,这里简单展示一下添加的方法
1 2 3 4 5 6 7 8 9 10 11 12 13
| CGRect mainViewBounds = self.navigationController.view.bounds; customSearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(CGRectGetMinX(mainViewBounds), CGRectGetMinY(mainViewBounds) + 44.0, self.navigationController.view.bounds.size.width, 40)]; customSearchBar.delegate = self; customSearchBar.showsCancelButton = YES; [self.navigationController.view addSubview: customSearchBar]; CGRect viewBounds = self.navigationController.view.bounds; [self.view setFrame:CGRectMake(CGRectGetMinX(viewBounds), CGRectGetMinY(viewBounds) + 40, CGRectGetWidth(viewBounds), CGRectGetHeight(viewBounds) - 128)];
|