change color searchBar result icon swift

后端 未结 2 1557
独厮守ぢ
独厮守ぢ 2020-12-06 23:04

how can I change color of result icon by code in swift?

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-06 23:56

    let sb = UISearchBar()
    
        sb.searchBarStyle = UISearchBarStyle.minimal
        sb.showsSearchResultsButton = true
       // sb.setClearButtonColorTo(color: UIColor.white)
    
        let textFieldInsideSearchBar = sb.value(forKey: "searchField") as? UITextField
        let crossIconView = textFieldInsideSearchBar?.value(forKey: "clearButton") as? UIButton
        crossIconView?.setImage(crossIconView?.currentImage?.withRenderingMode(.alwaysTemplate), for: .normal)
        crossIconView?.tintColor = .white
    

提交回复
热议问题