基本上我正在尝试设置我的 UINavigationBar
的背景颜色,但它没有显示任何内容。
请问,我该如何解决这个问题?!太感谢了 !!
这是我在 viewDidLoad
中的代码:
[super viewDidLoad];
self.filteredContentList = [[NSMutableArray alloc] init];
// Do any additional setup after loading the view.
self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 50, CGRectGetWidth(self.collectionView.frame), 30)];
self.searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
self.searchBar.placeholder = @"Search...";
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:CellIdentifier];
self.collectionView.backgroundColor = [UIColor whiteColor];
[self.collectionView addSubview:self.searchBar];
[self.view addSubview:self.searchBar];
[self.collectionView setContentOffset:CGPointMake(0, 44)];
[self.collectionView setContentInset:UIEdgeInsetsMake(80, 0, 0, 0)];
self.navigationController.navigationBar.backgroundColor = [UIColor greenColor];
最佳答案
这适用于 iOS 7,您可以适应上面的代码:
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
[navBar setBarTintColor:[UIColor greenColor]];
UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 50, CGRectGetWidth(navBar.frame), 30)];
searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
searchBar.placeholder = @"Search...";
[self.view addSubview:searchBar];
[self.view addSubview:navBar];
关于ios - UICollectionview 隐藏导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23146000/