![](/img/trans.png)
[英]How to change Background Color and Placeholder position of UISearchBar
[英]How to change background color of UiSearchBar to black -SWIFT
我按照下面的编程方式创建了UISearchBar,按钮看起来是第二个图像。如何清除搜索栏的白色并将背景颜色设置为黑色
var categorySearchBar : UISearchBar = UISearchBar()
categorySearchBar.frame = CGRectMake(0, 20, self.view.frame.size.width, 30)
categorySearchBar.layer.borderColor = UIColor.grayColor().CGColor
categorySearchBar.layer.borderWidth = 1.0
categorySearchBar.placeholder = "SEARCH"
categorySearchBar.barTintColor = UIColor.blackColor()
self.view.addSubview(categorySearchBar)
您可以使用UISearchBar的 barStyle属性,如果您使用的是故事板,则可以使用Attribute Inspector更改条形样式,或使用以下代码段。 它可能有助于交配:)
categorySearchBar.barStyle = UIBarStyle.Black
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.