更改颜色searchBar结果图标swift

前端之家收集整理的这篇文章主要介绍了更改颜色searchBar结果图标swift前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

如何在swift中通过代码更改结果图标的颜色?

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
原文链接:https://www.f2er.com/swift/320096.html

猜你在找的Swift相关文章