用kVo方式改變:(由于系統(tǒng)默認(rèn)placeholder的創(chuàng)建方式是動(dòng)態(tài)的,所以這個(gè)方法一定要在設(shè)置了placeholder的情況下屎暇,才能正常執(zhí)行)
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)