【问题标题】:when focused remove underline from material entry control in xamarin forms for ios当重点从 ios 的 xamarin 表单中的材料输入控件中删除下划线时
【发布时间】:2021-07-30 07:26:30
【问题描述】:
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 中的材料条目时,它会显示有下划线。请帮我删除 ios 中 xamarin.forms 的下划线

【问题讨论】:

    标签: xamarin xamarin.forms material-design


    【解决方案1】:

    尝试将活动下划线高度设置为0f

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-05
      • 2020-10-03
      • 2021-08-27
      • 2021-10-23
      • 2018-03-12
      • 1970-01-01
      相关资源
      最近更新 更多