搜索条UISearchBar自定义样式 去掉上下阴影下划线 修改取消按钮的文字、颜色 - Swift

xiaoxiao2021-02-28  123

修改字体和颜色:

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 { // Fallback on earlier versions }

去掉上下阴影下划线

searchBar.layer.borderWidth = 1 searchBar.layer.borderColor = UIColor.white.cgColor

修改Cancel按钮的字:

searchBar.setValue("取消", forKey: "_cancelButtonText")
转载请注明原文地址: https://www.6miu.com/read-25759.html

最新回复(0)