首页 > 解决方案 > 在 Xamarin 表单 Ios 中使用 MaterialEntryRenderer Placeholdercolor 和 Cursorcolor 未更改

问题描述

如何在 ios 渲染器中更改占位符颜色和光标颜色?我已经更改了占位符中的 TintColor 属性和 Control.AttributedPlaceholder 中的光标颜色,它没有更改 ios 中的占位符颜色和光标颜色

公共类 CustomMaterialEntryRenderer : MaterialEntryRenderer {

}

标签: xamarinxamarin.formsxamarin.ios

解决方案


这里我们不需要使用MaterialEntryRenderer .

只需PlaceholderColor在 Forms 项目中设置,它就会改变占位符和光标颜色。

<Entry Placeholder="test" Visual="Material" Focused="Entry_Focused" Unfocused="Entry_Unfocused"/>

private void Entry_Focused(object sender, FocusEventArgs e)
{
   var entry = sender as Entry;
   entry.PlaceholderColor = Color.Red;
}

private void Entry_Unfocused(object sender, FocusEventArgs e)
{
   var entry = sender as Entry;
   entry.PlaceholderColor = Color.Gray;
}

推荐阅读