如何在XARARIN中为ANDROID和iOS更改Picker占位符的颜色? PlaceholderColor =“white”不起作用。
<Picker Title="Search items" TextColor="White"
PlaceholderColor = "white"
VerticalOptions="Start">
<Picker.Items>
<x:String>Item1</x:String>
<x:String>item2</x:String>
<x:String>item3</x:String>
</Picker.Items>
</Picker>
答案 0 :(得分:5)
您需要一个自定义渲染器:
[assembly: ExportRenderer(typeof(Picker), typeof(CustomPicker))]
namespace Droid
{
public class CustomPicker : PickerRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
base.OnElementChanged (e);
if (Control != null)
Control.SetHintTextColor (Android.Graphics.Color.Rgb(1,2,3));
}
}
}
答案 1 :(得分:3)
在iOS中,您可以在自定义渲染器中执行类似操作。
Control.AttributedPlaceholder =
new NSAttributedString (Control.AttributedPlaceholder.Value, foregroundColor: UIColor.White);