0

프로그래밍 방식으로 UISearchController를 사용하여 생성 된 navBar를 사용했습니다. 나는 UISearchBar 편집을 시작하면
는 :

을 - 네비게이션 바는 희미한보기
뒤에 유지 - tabeView가 나타 났을 때, 버튼을 선택할 수 없습니다 취소 -있는 tableView는 네비게이션 바
의 절반을 숨 깁니다.


UISearchController, Swift 앞에서 navbar 가져 오기


내 UISearchController :

let locationSearchTable = storyboard!.instantiateViewControllerWithIdentifier("SearchTableViewController") as! SearchTableViewController 
    resultSearchController = UISearchController(searchResultsController: locationSearchTable) 
    resultSearchController.searchResultsUpdater = locationSearchTable 
    resultSearchController.view.backgroundColor=UIColor.clearColor() 
    locationSearchTable.delegate = self 

    let searchBar = self.resultSearchController.searchBar 
    searchBar.sizeToFit() 
    searchBar.placeholder = "Search" 
    searchBar.searchBarStyle = .Minimal 
    searchBar.barStyle = .Default 
    searchBar.translucent = true 
    searchBar.barTintColor = UIColor.whiteColor() 
    searchBar.setImage(UIImage(named:"search"), forSearchBarIcon: .Search, state : .Normal) 
    searchBar.delegate=self 
    resultSearchController.hidesNavigationBarDuringPresentation = false 
    resultSearchController.dimsBackgroundDuringPresentation = true 
    definesPresentationContext = true 


내 네비게이션 바 :

let newNavBar : UINavigationBar = UINavigationBar.init(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, 64.0)) 

func styleNavBar(){ 

    UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.Default 
    self.navigationController?.setNavigationBarHidden(true, animated: false) 


    let newItem : UINavigationItem = UINavigationItem.init() 
    newItem.titleView = self.resultSearchController.searchBar 

    newNavBar.barTintColor = UIColor(red: 243/255, green: 242/255, blue: 238/255, alpha: 1.0) 
     newNavBar.translucent = false 
     if let font = UIFont(name: "Avenir-Black", size: 16.0) { 
      let navBarAttributesDictionary : [String : AnyObject]? = [ 
       NSForegroundColorAttributeName: UIColor(red: 74/255, green: 74/255, blue: 74/255, alpha: 0.51), 
       NSFontAttributeName: font 
      ] 
      newNavBar.titleTextAttributes = navBarAttributesDictionary 
     } 

    newNavBar.setItems([newItem], animated: false) 

    self.view.addSubview(newNavBar) 
    self.view.bringSubviewToFront(newNavBar) 
} 

enter image description here

가 어떻게, 제발 해결할 수 있습니까?
감사합니다.

+0

당신이 만든 코드가 더 좋을 것 같아 – Tj3n

+0

@ Tj3n 내 게시물을 업데이트했습니다! ;) –

답변

0

stackview를 사용할 수 있습니다. 검색 및있는 tableview를 선택하고에서 stackview 및 제약 stackview에 마우스 오른쪽/아래/좌/상단

enter image description here

+0

내 게시물을 업데이트했습니다.) –

+0

ok. 당신은 stackview 객체를 생성 할 수 있으며 대신 newNavBar를 stackview와 locationSearchTable에 추가 할 수 있습니다. –

1

이 사용해보십시오 :

self.navigationController .navigationBar.layer.zPosition = 1

관련 문제