Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dkudelko/f256d10968c7c8b6a63447714d1d5b97 to your computer and use it in GitHub Desktop.
Save dkudelko/f256d10968c7c8b6a63447714d1d5b97 to your computer and use it in GitHub Desktop.
Xamarin.Forms renderer to hide the "Cancel" button of a SearchBar on iOS
using System;
using Xamarin.Forms.Platform.iOS;
using Xamarin.Forms;
using UIKit;
using System.Diagnostics;
[assembly: ExportRenderer(typeof(SearchBar), typeof(Namespace.iOS.Renderers.ExtendedSearchBarRenderer))]
namespace Namespace.iOS.Renderers
{
public class ExtendedSearchBarRenderer : SearchBarRenderer
{
protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == "Text")
{
Control.ShowsCancelButton = false;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment