당신은 그것을 볼 수없는 이유를 UIBarButtonItem
로, 이잖아 검색 창을 추가했습니다.
당신은 탐색의 제목 대신에 탐색 모음을 표시 탐색 모음 사용이 코드
코드의 제목보기 대신에 검색 창을 표시하려면 :
UISearchBar *searchBar = [[UISearchBar alloc]init];
searchBar.tintColor = [UIColor grayColor];
searchBar.backgroundColor = [UIColor redColor];
searchBar.placeholder = @"Search";
self.navigationItem.titleView = searchBar;
출력 :에
코드 탐색 표시 줄 아래에 표시 탐색 모음 :
UISearchBar *searchBar1 = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 64, [UIScreen mainScreen].bounds.size.width, 64)];
searchBar1.tintColor = [UIColor grayColor];
searchBar1.backgroundColor = [UIColor redColor];
searchBar1.placeholder = @"Search";
[self.view addSubview:searchBar1];
UPDATE :
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
searchBar1.searchBarStyle = UISearchBarStyleMinimal;
UISearchBar *searchBar1 = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 64, [UIScreen mainScreen].bounds.size.width, 64)];
searchBar1.tintColor = [UIColor grayColor];
searchBar1.searchBarStyle = UISearchBarStyleMinimal;
searchBar1.backgroundColor = [UIColor redColor];
searchBar1.placeholder = @"Search";
[self.view addSubview:searchBar1];
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setDefaultTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
출력 :
업데이트 출력
가 텍스트 필드를 사용자 정의하려면 :
UISearchBar *searchBar1 = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 64, [UIScreen mainScreen].bounds.size.width, 64)];
searchBar1.tintColor = [UIColor grayColor];
searchBar1.searchBarStyle = UISearchBarStyleMinimal;
searchBar1.backgroundColor = [UIColor redColor];
searchBar1.placeholder = @"Search";
[self.view addSubview:searchBar1];
[searchBar1 setSearchFieldBackgroundImage:[UIImage imageNamed:@"text-input.png"] forState:UIControlStateNormal];
이미지는 검색 창의 텍스트 필드와 같이 높이가 30 픽셀입니다.
그리고 출력 : 여기
은 이미지입니다
는 희망이 도움이 ...
해피 코딩 ...
가 일부 화면이 유 –
무슨 문제가 당신을 필요로 어떻게 총을 표시 할 수 있습니다 ..
viewcontroller.m
에 가서 다음 코드이제
가 잘 작동 붙여 넣기 얼굴? 일부 화면으로 알려주십시오. –
네비게이션 바 안의 네비게이션 바 또는 내비게이션 바 아래쪽 –