如何将UiSearchBar的背景颜色更改为黑色-SWIFT [英] How to change background color of UiSearchBar to black -SWIFT
本文介绍了如何将UiSearchBar的背景颜色更改为黑色-SWIFT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我以编程方式创建了UISearchBar,如下所示,该按钮似乎是第二张图片。如何清除搜索栏的白色并将背景颜色设置为黑色
I created UISearchBar programmatically as below and the button appears to be of second image.How to clear the white color of search bar and set background colour to Black
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)
推荐答案
你可以使用 barStyle UISearchBar 的属性,如果您是我们的话故事板您可以使用Attribute Inspector更改条形样式,或使用以下代码段。它可能有助于交配:)
You can use barStyle property of UISearchBar , if you are using story board you can use Attribute Inspector to change bar style, or use following code segment. It might help mate :)
categorySearchBar.barStyle = UIBarStyle.Black
这篇关于如何将UiSearchBar的背景颜色更改为黑色-SWIFT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文