ios - Bring navbar in front of the UISearchController, Swift -


i used navbar created programmatically uisearchcontroller.
when start editing uisearchbar:

- navbar stays behind dim view
- tableview hides half of navbar
- when tabeview appeared, cancel buttons not selectable.



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 


navbar :

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

how can fix it, please?
thanks!

try using :

self.navigationcontroller?.navigationbar.layer.zposition = 1


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -