修改UISearchBar的TextField的背景颜色

  • Post author:
  • Post category:其他



UIView


*searchTextField =


nil


;

//





测试


,


需要设置


barTintColor





,


才能拿到


UISearchBarTextField


对象

_searchBar


.


barTintColor


= [


UIColor




clearColor


];

searchTextField = [[[


_searchBar


.


subviews




firstObject


]


subviews


]


lastObject


];

searchTextField.


backgroundColor


=

(自己可以随意设置背景颜色)

;

if


([searchTextField


isKindOfClass


:[


UITextField




class


]]) {




UITextField


*textField = (


UITextField


*)searchTextField;

textField.


textColor


=


(自己可以随意设置字体颜色)

}



版权声明:本文为boyan92626原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。