UISearchBar placeHolder and leftView is dissappearing.

I have UISearchBar, when I run from xCode placeholder and icon is working well but when i run from simulator or testflight placeholder and icon is dissappear. How can I solve it?

Here my code:

view:

    private lazy var searchBar: UISearchBar = {
        let view = UISearchBar()
        view.delegate = self
        view.barTintColor = UIColor.clear
        view.backgroundColor = UIColor.clear
        view.isTranslucent = true
        view.setBackgroundImage(UIImage(), for: .any, barMetrics: .default)
        view.placeholder = "Search"
        return view
    }()

setup method:

        view.addSubview(searchBar)
        view.addSubview(collectionView)
        
        searchBar.snp.makeConstraints { make in
            make.top.equalTo(view.safeAreaLayoutGuide).inset(17)
            make.leading.trailing.equalToSuperview().inset(6)
            make.height.equalTo(40)
        }

I think the most likely issue is your forcing the height to 40pts, which is not the native height of the search bar. Does the search bar render correctly if you remove that constraint?

But given everything you are doing to make the search bar not display any additional background, perhaps you should use UISearchTextField instead?

UISearchBar placeHolder and leftView is dissappearing.
 
 
Q