Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change border and icons in Search bar (Swift)

I have this:

http://postimg.org/image/ag29m3e7d/

and I need this

http://postimg.org/image/4bacislw5/

I have to create border or set it by image? How to change search icons(magnifier and X icon) or could I change just colors?

Sorry for links but I cannot insert images here.

like image 957
Lifeplus Avatar asked Jul 14 '15 17:07

Lifeplus


1 Answers

To add borders use the views layer property.

self.searchBar.layer.borderColor = UIColor.blueColor().CGColor
self.searchBar.layer.borderWidth = 1

If you want to add the corner radius to the searchBar:

self.searchBar.layer.cornerRadius = 3.0
self.searchBar.clipsToBounds = true

To change the searchIcon call the following method on the searchbar:

self.searchbar.setImage(image, icon: UISearchBarIcon. UISearchBarIcon.Search, state: UIControlState.Normal)

To change the cross:

self.searchbar.setImage(image, icon: UISearchBarIcon. UISearchBarIcon.Clear, state: UIControlState.Normal)
like image 152
villy393 Avatar answered Oct 13 '22 18:10

villy393