如何在IOS中删除选择器边框

我正在尝试添加带有背景图像的选择器,因此我使用相对布局并在相对布局中添加了图像和选择器.

我的问题是我在
IOS的环境中有一个边框,我在
Android设备上有一个底线.

我在正常输入中遇到了这个问题并解决了但是我在选择器中使用相同的场景无法正常工作.

这是守则

<RelativeLayout Margin="0,0,0,0"
                                    Padding="0,0,0,0"
                                    >
                        <Image Source="input_mobile_code_brown.png"
                               x:Name="img"

                               RelativeLayout.XConstraint =
                    "{ConstraintExpression Type=RelativeToParent,
                         Property=Width,
                         Factor=0,
                         Constant=0}"
                RelativeLayout.YConstraint =
                    "{ConstraintExpression Type=RelativeToParent,
                         Property=Height,
                         Factor=0,
                         Constant=0}"
                                  RelativeLayout.WidthConstraint =
                    "{ConstraintExpression Type=RelativeToParent,

                         Property=Width,
                         Factor=1,
                         Constant=0}"
               RelativeLayout.HeightConstraint =
                    "{ConstraintExpression Type=RelativeToParent,

                         Property=Height,
                         Factor=1,
                         Constant=0}"
                               />
                        <Picker BackgroundColor="Transparent"
                                x:Name="picker" 
                                Margin="10,0,0,0"

                RelativeLayout.XConstraint =
                    "{ConstraintExpression Type=RelativeToParent,
                         Property=Width,
                         Factor=0,
                         Constant=0}"
                RelativeLayout.YConstraint =
                    "{ConstraintExpression Type=RelativeToParent,
                         Property=Height,
                         Factor=0,
                         Constant=0}"
                RelativeLayout.WidthConstraint =
                    "{ConstraintExpression Type=RelativeToView,
                         ElementName=img,
                         Property=Width,
                         Factor=1,
                         Constant=0}"
               RelativeLayout.HeightConstraint =
                    "{ConstraintExpression Type=RelativeToView,
                         ElementName=img,
                         Property=Height,
                         Factor=1,
                         Constant=0}"
            />
                    </RelativeLayout>

>这是结果

《如何在IOS中删除选择器边框》

我需要从IOS中删除默认边框

所以我在IOS中制作了一个customRenderer

protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
    base.OnElementChanged(e);
    var view = e.NewElement as CustomPicker;
    this.Control.BorderStyle=  UITextBorderStyle.None;
}

但是在IOS中仍未删除边框

最佳答案 您只需要在xaml中将Picker修改为CustomPicker,如下所示:

<local:CustomPicker BackgroundColor="Transparent" .../>

然后它会运作良好.

点赞