Home > Back-end >  Can't hide the top and bottom lines in custom searchBar
Can't hide the top and bottom lines in custom searchBar

Time:08-22

image link: https://github.com/Tambanco/issueSearchBar/blob/main/issue_Lines.jpg

I´ve tried to change background color inside class SearchBarView: UIView {}:

searchBar.searchTextField.backgroundColor = .clear
searchBar.backgroundColor = .clear

and tryed something like that inside MainViewController:

searchBar.searchTextField.backgroundColor = .clear
searchBar.backgroundColor = .clear
searchBar.layer.backgroundColor = UIColor.clear.cgColor

but, unfortunately I still see this lines inside my custom searchBar. How can I get rid of these lines?

CodePudding user response:

If you want to make the top and bottom border lines on the textfield disappear (the dark gray ones), you will want to tweak the text field's border properties rather than the background colors. Try something like this:

searchBar.searchTextField.layer.borderWidth = 0

or

searchBar.searchTextField.layer.borderColor = UIColor.clear.cgColor

and adapt it to fit how you've set up the relevant subviews in your custom search bar.

CodePudding user response:

You could try:

searchBar.backgroundImage = UIImage()
  • Related