protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e) { base.OnElementChanged(e); if (Control == null || e.OldElement != null || this.Element == null) { return; } Control.Background = null; _appSearchBar = (this.Element as AppSearchBar); UpdatePadding(_appSearchBar); UpdateTextAlighnment(_appSearchBar); UpdateBackground(_appSearchBar); }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e) { base.OnElementChanged(e); if (Control == null || e.OldElement != null || this.Element == null) { return; } //Control.SearchBarStyle = UISearchBarStyle.Minimal; //Control.BarTintColor = UIColor.Clear; _appSearchBar = (this.Element as AppSearchBar); UpdateBorderWidth(_appSearchBar); UpdateBorderColor(_appSearchBar); UpdateBorderRadius(_appSearchBar); Control.ClipsToBounds = true; }
private void UpdateBackground(AppSearchBar searchBar) { // creating gradient drawable for the curved background var _gradientBackground = new GradientDrawable(); _gradientBackground.SetShape(ShapeType.Rectangle); _gradientBackground.SetColor(searchBar.BackgroundColor.ToAndroid()); // Thickness of the stroke line _gradientBackground.SetStroke(searchBar.BorderWidth, searchBar.BorderColor.ToAndroid()); // Radius for the curves _gradientBackground.SetCornerRadius(DpToPixels(this.Context, Convert.ToSingle(searchBar.CornerRadius))); // set the background of the Control.SetBackground(_gradientBackground); }
private void UpdateBorderRadius(AppSearchBar searchBar) { Control.Layer.CornerRadius = (nfloat)searchBar.CornerRadius; }
private void UpdateBorderColor(AppSearchBar searchBar) { Control.Layer.BorderColor = searchBar.BorderColor.ToUIColor().CGColor; }
private void UpdateBorderWidth(AppSearchBar searchBar) { Control.Layer.BorderWidth = searchBar.BorderWidth; }
private void UpdatePadding(AppSearchBar searchBar) { // Set padding for the internal text from border Control.SetPadding((int)DpToPixels(this.Context, Convert.ToSingle(12)), Control.PaddingTop, (int)DpToPixels(this.Context, Convert.ToSingle(12)), Control.PaddingBottom); }