用kVo方式改变:(由于系统默认placeholder的创建方式是动态的,所以这个方法一定要在设置了placeholder的情况下,才能正常执行)
let textFiled: UITextField = searBar.value(forKey: "_searchField") as! UITextField
let lable: UILabel = textFiled.value(forKey: "_placeholderLabel") as! UILabel
lable.textColor = UIColor.red
改变searBar的放大镜的图片:
let imageq = UIImage.init(named: "形状-40")
searBar.setImage(imageq, for: UISearchBarIcon.search, state: .normal)
网友评论