答案 0 :(得分:1)
事实证明问题是由MaterialEntryRenderer
中的逻辑引起的。
找到方法SetPlaceholderColor
,它会更改placeholderColr渲染。
修改如下:
private void SetPlaceholderColor()
{
if (Element.PlaceholderColor == Color.Default)
{
Control.FloatingLabelTextColor = _defaultPlaceholderColor;
Control.AttributedPlaceholder = new NSAttributedString(Control.Placeholder, new UIStringAttributes { ForegroundColor = _defaultPlaceholderColor });
}
else {
Control.FloatingLabelTextColor = Element.PlaceholderColor.ToUIColor();
Control.AttributedPlaceholder = new NSAttributedString(Control.Placeholder, new UIStringAttributes { ForegroundColor = Element.PlaceholderColor.ToUIColor() });
}
}
然后您可以根据需要更改占位符颜色。
var userNameEntry = new Entry()
{
Placeholder = "UserName",
PlaceholderColor = Color.Red,
TextColor = Color.Green,
};
var passwordEntry = new Entry()
{
Placeholder = "Password",
PlaceholderColor = Color.Black,
TextColor = Color.Gray,
};