修改字体和颜色:
let attributes = [
NSForegroundColorAttributeName :
UIColor.white,
NSFontAttributeName :
UIFont.systemFont(ofSize:
17)
]
if #available(iOS 9.0, *) {
UIBarButtonItem.appearance(whenContainedInInstancesOf: [
UISearchBar.self])
.setTitleTextAttributes(attributes,
for:
.normal)
}
else {
}
去掉上下阴影下划线
searchBar
.layer.borderWidth =
1
searchBar
.layer.borderColor = UIColor
.white.cgColor
修改Cancel按钮的字:
searchBar.setValue(
"取消",
forKey:
"_cancelButtonText")