UISearchBar cancel button color?

前端 未结 11 522
耶瑟儿~
耶瑟儿~ 2020-12-13 09:00

When I drop a UISearchBar into my view inside Interface Builder, and change its style to Black Opaque, the cancel button stays unfittingly blue / gray and doesn\'t become bl

11条回答
  •  时光说笑
    2020-12-13 09:33

    For those looking to reproduce the same behavior in Swift :

    override func viewWillAppear(animated: Bool) {
        self.searchBar.tintColor = UIColor.whiteColor()
    
        let view: UIView = self.searchBar.subviews[0] as! UIView
        let subViewsArray = view.subviews
    
        for (subView: UIView) in subViewsArray as! [UIView] {
            println(subView)
            if subView.isKindOfClass(UITextField){
                subView.tintColor = UIColor.blueColor()
            }
        }
    
    }
    

提交回复
热议问题