Xamarin.Forms菜鸟笔记--6.自定义无边框输入框Entry

Xamarin.Forms默认的Entry在ios下是四周圆角样式的输入框,在安卓下是底部横线
有时候我们想自定义输入样式,比如
在这里插入图片描述
官方给了自定义输入框的demo,传送门:https://docs.microsoft.com/zh-cn/xamarin/xamarin-forms/app-fundamentals/custom-renderer/entry

我们只需要稍微对demo修改一下就可以

// 这里不用改

public class MyEntry : Entry
{
}

ios下,修改BorderStyle 为空

using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer (typeof(MyEntry), typeof(MyEntryRenderer))]
namespace CustomRenderer.iOS
{
    public class MyEntryRenderer : EntryRenderer
    {
        protected override void OnElementChanged (ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged (e);

            if (Control != null) {
               Control.

猜你喜欢

转载自blog.csdn.net/qq_21703215/article/details/105562737