I\'m having trouble removing that 1px border directly under the UISearchBar vi
[searchBar setBackgroundImage:[UIImage new]];
Nevermind, I just did:
searchBar.layer.borderWidth = 1;
searchBar.layer.borderColor = [[UIColor whiteColor] CGColor];
and it works!
For Swift version, tested on iOS9:
searchBar.backgroundImage = UIImage()
It would show like this:
In order to overcome this in Xamarin Forms, you'll need to create a CustomRenderer
to the SearchBar
class.
Like this:
using System;
using Xamarin.Forms.Platform.iOS;
using Xamarin.Forms;
using MyProject.iOS;
[assembly: ExportRenderer(typeof(SearchBar), typeof(CustomSearchBarRenderer))]
namespace MyProject.iOS
{
public class CustomSearchBarRenderer:SearchBarRenderer
{
protected override void OnElementChanged (ElementChangedEventArgs<Xamarin.Forms.SearchBar> e)
{
base.OnElementChanged (e);
if (this.Control == null) return;
this.Control.BackgroundImage = new UIKit.UIImage ();
}
}
}