我想指定 UISearchBar 的底部边框颜色。我已经看到很多答案,这些答案将有助于摆脱边框,或设置整体边框颜色,但我只想设置底部边框的边框颜色。这是我的代码:
searchController.searchBar.layer.borderWidth = 1
searchController.searchBar.layer.borderColor = UIColor.white.cgColor
有没有办法仅设置底部边框的边框颜色?
最佳答案
只需向文本字段添加一个 subview ,如下所示
let frame = CGRectMake(0, textField.frame.size.height - 1, textField.frame.size.width, 1)
let border = UIView(frame: frame)
border.backgroundColor = UIColor.whiteColor()
textField.addSubview(border)
关于ios - 如何在 Swift3 中的 UISearchBar 上设置边框底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39859742/