A background view remains visible when you try to hide SearchBar through the alpha

I’m having trouble hiding SearchBar on NavigationItem.(Xcode 9 | Swift 4)

ex: https://www.dropbox.com/s/6is5mukpk1yew8e/bgSearch.gif?dl=0 Using this code:

 

func scrollViewDidScroll (_ scrollView: UIScrollView) { let transp: Float = Float (1 - (mTableView.contentOffset.y / (mTableView.contentSize.height - mTableView.frame.size.height) * 60)) self.navigationController! .navigationBar.alpha = CGFloat (transp) self.mSearchController.searchBar.alpha = CGFloat (transp) titleMsgView.alpha = CGFloat (transp) }

 

Everything works fine, except for a background that I could not access to hide with the alpha. I’m using:

 

viewDidLoad() { mSearchController = UISearchController (searchResultsController: nil) mSearchController.delegate = self as? UISearchControllerDelegate mSearchController.searchResultsUpdater = self navigationItem.searchController = mSearchController } 

 

As the SerchBar search field disappears correctly, you will understand that it is something with the NavigationItem to which it has been added. Could someone help me solve the problem?

Powered by WPeMatico

About

You may also like...

Comments are closed.