Skip to content

Instantly share code, notes, and snippets.

@varun-raj
Forked from xleon/ExtendedSearchBarRenderer.cs
Created December 28, 2018 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save varun-raj/91f0b4c932de671f4174b5b01d60d818 to your computer and use it in GitHub Desktop.
Save varun-raj/91f0b4c932de671f4174b5b01d60d818 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