我想要更改我的UISearchBar背景图片。
当我将它添加为UITableView的标题视图时,它可以完美地工作。但是,当我想要为设置为navigationItem搜索控制器的SearchBar更改它时,它不会更改背景图片。
我正在使用:
self.searchBar.searchBar.setBackgroundImage(UIImage(named: "#IMAGENAME")?.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch), for: .any, barMetrics: UIBarMetrics.default)
有人知道如何解决这个问题吗?
navigationItem.searchController = sc
为navigationItem.titleView = sc.searchBar
。 - Yash Bedi