1

기본적으로 내 UINavigationBar의 배경색을 설정하려고하지만 아무 것도 표시하지 않습니다.UICavigation 표시 숨기기 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]; 
+0

사용하고있는 아이폰 OS 버전? – Winston

+0

@Winston은 현재 iOS7을 사용합니다 – ipalibowhyte

답변

1

이 아이폰 OS 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]; 
+0

감사합니다. 잘 작동합니다. D! – ipalibowhyte

+0

여러분을 환영합니다! – Winston

관련 문제