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

来源:互联网 发布:php qq发邮件源代码 编辑:程序博客网 时间:2024/06/07 07:49

修改字体和颜色:

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 = 1searchBar.layer.borderColor = UIColor.white.cgColor

修改Cancel按钮的字:

searchBar.setValue("取消", forKey: "_cancelButtonText")
阅读全文
0 0
原创粉丝点击