标签:object-c searchbar round 颜色 str 状态 ini object controls
// 记住最初的状态,用完的时候用这个还原
self.cancelBtnTextAttribute = UIBarButtonItem.appearance().titleTextAttributes(for: UIControlState.normal) as [String : AnyObject]?
let cancelBtn:UIButton = self.searchBar.subviews[0].subviews[2] as! UIButton
// 设置自定义的状态
cancelBtn.setTitle("取消" ,for:UIControlState.normal)
let cancelButtonAttributes: NSDictionary = [NSForegroundColorAttributeName: UIColor.init(hex6: 0xF24500)]
UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes as? [String : AnyObject], for: UIControlState.normal)
当然object-c的也是一样的实现,只要把swift的语法转换成object-c的救行了。
标签:object-c searchbar round 颜色 str 状态 ini object controls
原文地址:http://www.cnblogs.com/codetime/p/6291535.html