swift 样式搜索栏最小取消按钮和 horizon 左侧

swift styling searchbar minimal cancel button and horizon left

我想更改搜索栏取消按钮图像或更改背景颜色 我需要水平向左

我已经试过了

if let btn = mSearchBar.value(forKey: "cancelButton") as? UIButton {
    btn.backgroundColor = .red  
}

但它不起作用

谢谢

Swift 5

@IBOutlet private weak var searchbar: UISearchBar!{
        didSet{
            if let searchTextfield = self.searchbar.value(forKey: "searchField") as? UITextField , let clearButton = searchTextfield.value(forKey: "_clearButton")as? UIButton {
                
                clearButton.setImage(UIImage(named: "cross_vector_icon"), for: .normal)
                
            }
             
        }
    }