Skip to content

Instantly share code, notes, and snippets.

@xleon
Created February 25, 2015 01:44
Show Gist options
  • Save xleon/9f94a8482162460ceaf9 to your computer and use it in GitHub Desktop.
Save xleon/9f94a8482162460ceaf9 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