2017-08-16 8 views
3

私は背景イメージを持つピッカーを追加しようとしているので、相対レイアウトを使用し、相対レイアウト内にイメージとピッカーの両方を追加しました。 私の問題は、私はIOSの環境に国境を持っており、私はアンドロイドデバイスのボトムラインを持っています。 ノーマルエントリでこの問題に直面して解決しましたが、ピッカーが動作しないときと同じシナリオを使用しました。ここでIOSのピッカーボーダーを削除する方法

は、これが結果

enter image description here

である私は、だから私はcustomRendererを作っIOS

からデフォルトの境界線を削除する必要があるコード

<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

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

    しかし、まだ境界はIOS

答えて

0

に除去されていないあなたは、このようなXAMLでCustomPickerピッカーを変更する必要があります

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

そして、それがうまく動作します。

+0

は仲間を働いていません! –

+0

@SumitPathak、@Victor Faltasのようなピッカーのカスタムレンダラーはありますか? @ Victor Faltasが質問したようにすべてのことをしてくれたことを確認してください。答えは「Picker」を「local:CustomPicker」に変更してください。 –

0

予想される回答は

<local:CustomPicker x:Name="modePicker" ... 

public class BorderlessPickerRenderer : PickerRenderer 
{ 
    public static void Init() { } 
    protected override void OnElementChanged(ElementChangedEventArgs<Picker> e) 
    { 
     base.OnElementChanged(e); 
     if (e.OldElement == null) 
     { 
      Control.Background = null; 

      var layoutParams = new MarginLayoutParams(Control.LayoutParameters); 
      layoutParams.SetMargins(0, 0, 0, 0); 
      LayoutParameters = layoutParams; 
      Control.LayoutParameters = layoutParams; 
      Control.SetPadding(0, 0, 0, 0); 
      SetPadding(0, 0, 0, 0); 
     } 
    } 
} 

レンダラ上でiOS用のAndroid

のためである - UWPについては

protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) 
    { 
     base.OnElementPropertyChanged(sender, e); 

     Control.Layer.BorderWidth = 0; 
     Control.BorderStyle = UITextBorderStyle.None; 
    } 

-

protected override void OnElementChanged(ElementChangedEventArgs<Picker> e) 
    { 
     base.OnElementChanged(e); 

     if (Control != null) 
     { 
      Control.BorderThickness = new Windows.UI.Xaml.Thickness(0); 
      Control.Margin = new Windows.UI.Xaml.Thickness(0); 
      Control.Padding = new Windows.UI.Xaml.Thickness(0); 
     } 
    } 
+0

しかし、それはすでに問題のiOSに適切なカスタムレンダラを持っています!言葉が出ません... –

関連する問題