How to change border and icons in search bar (Swift)
I have it:
http://postimg.org/image/ag29m3e7d/
and i need it
http://postimg.org/image/4bacislw5/
Do I need to create a border or set it on the image? How do I change the search icons (zoom and X) or can I only change the colors?
Sorry for the links, but I cannot insert images here.
+3
source to share
2 answers
To add borders, use the views layer
.
self.searchBar.layer.borderColor = UIColor.blueColor().CGColor
self.searchBar.layer.borderWidth = 1
If you want to add corner radius to searchBar:
self.searchBar.layer.cornerRadius = 3.0
self.searchBar.clipsToBounds = true
To change your search, do the following in the search bar:
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)
+11
source to share