Lif*_*lus 3 uisearchbar ios swift
我有这个:
http://postimg.org/image/ag29m3e7d/
我需要这个
http://postimg.org/image/4bacislw5/
我必须创建边框或按图像设置它?如何更改搜索图标(放大镜和X图标)还是可以更改颜色?
对不起链接,但我不能在这里插入图像.
vil*_*393 16
要添加边框,请使用views layer属性.
self.searchBar.layer.borderColor = UIColor.blueColor().CGColor
self.searchBar.layer.borderWidth = 1
Run Code Online (Sandbox Code Playgroud)
如果要将角半径添加到searchBar:
self.searchBar.layer.cornerRadius = 3.0
self.searchBar.clipsToBounds = true
Run Code Online (Sandbox Code Playgroud)
要更改searchIcon,请在搜索栏上调用以下方法:
self.searchbar.setImage(image, icon: UISearchBarIcon. UISearchBarIcon.Search, state: UIControlState.Normal)
Run Code Online (Sandbox Code Playgroud)
要改变十字架:
self.searchbar.setImage(image, icon: UISearchBarIcon. UISearchBarIcon.Clear, state: UIControlState.Normal)
Run Code Online (Sandbox Code Playgroud)