1

I trying to change the Search Bar Display style in Xamarin IOS. But i couldn't make it properly. Please find the below images.

Default Search bar

Default Search Bar In Xamarin IOS

Required Search bar

enter image description here

I want to display search bar in required styles. I tried to remove the gray color and border from default search bar, but i couldn't make it.

Can any one suggest me, How to change the default search bar style to required search bar style.

Ranjith Kumar Nagiri
  • 865
  • 3
  • 18
  • 42

2 Answers2

1

I don't see a way to left align the placeholder text, but part of what you are looking for might be achieved by setting the search bar style:

searchBar.SearchBarStyle = UISearchBarStyle.Minimal;

UISearchBarStyle.Minimal

Otherwise you will have to not use the built in search bar but create your own view. See: https://stackoverflow.com/a/20384021/2913599

where the accepted answer is: "Don't use a UISearchBar if you need to do these kinds of customizations. You'll have to make your own using a UITextField and a UIImageView, and responding to the delegate calls."

However that thread has some other ideas about aligning the placeholder text to the left. The only one I could get to work was to add space padding to the placeholder text, e.g.:

searchBar.Placeholder = "Search ";

How many spaces you need to pad with of course depends in the search bar width. With the added space padding I got this:

enter image description here

Community
  • 1
  • 1
jgoldberger - MSFT
  • 5,978
  • 2
  • 20
  • 44
0

Set BackgroundColor property to Transparent.

eakgul
  • 3,658
  • 21
  • 33