UISearchbar add navigationController?.navigationBar。如何更改「取消」顏色UISearchbar add navigationController?.navigationBar,如何更改「取消」顏色
_searchBar = UISearchBar(frame: CGRect(frame: CGRect(x: 0, y: 0, width: 414, height: 64)))
_searchBar!.delegate = self
_searchBar!.showsCancelButton = true
backgroundColor = .white
barTintColor = .white
tintColor = .red
backgroundImage = UIImage()
_searchBar!.placeholder = "搜索文件"
navigationController?.navigationBar.addSubview(_searchBar!)
此結果是「取消」顏色爲白色。我如何將它設置爲紅色?
看到這個曾經https://stackoverflow.com/questions/35302760/如何改變取消按鈕上的uisearchbar-in-swift –