集中精力时,从Xamarin形式的ios的材质输入控件中删除下划线

问题描述

using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using Xamarin.Forms.Material.iOS;
using MyApp.iOS;
using MyApp;
using UIKit;
using System.ComponentModel;

[assembly: ExportRenderer(typeof(CustomMaterialEntry),typeof(CustomMaterialEntryRenderer),new[] { typeof(VisualMarker.MaterialVisual) })]

namespace MyApp.iOS
{
public class CustomMaterialEntryRenderer : MaterialEntryRenderer
{
/// <summary>
/// Element Changed Event
/// </summary>
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);

if (this.Control != null)
{
 UITextField UpdatedEntry = (UITextField)Control;
 UpdatedEntry.Background = null;
 UpdatedEntry.BackgroundColor = UIColor.Clear;
}
}
  protected override void OnElementPropertyChanged(object sender,PropertyChangedEventArgs e)
 {
  base.OnElementPropertyChanged(sender,e);
  if (this.Control != null)
   this.Control.Underline.Color = UIColor.Clear;
  }
}
}

对于android,它可以工作,但是当专注于ios中的材料输入时,它会显示带下划线。请帮助我删除xamarin.forms的ios中的下划线

解决方法

尝试将有效的下划线高度设置为0f

protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
    {
        base.OnElementChanged(e);
        if (this.Control != null)
        {
            Control.ActiveTextInputController.UnderlineHeightActive = 0f;
        }
    }