gpt4 book ai didi

ios - UICollectionview 隐藏导航栏

转载 作者:行者123 更新时间:2023-11-29 12:48:03 25 4
gpt4 key购买 nike

基本上我正在尝试设置我的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com