【发布时间】:2021-01-20 10:35:51
【问题描述】:
在开发 Xamarin.iOS 应用程序时,我能够为 backgroundColors 指定动态系统颜色以自动调整明暗模式。
例如:
if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
{
goalsCard.BackgroundColor = UIColor.SystemBackgroundColor;
}
else
{
goalsCard.BackgroundColor = UIColor.White;
}
现在,当使用 .xaml 文件并且不使用主题时,我希望能够做同样的事情,例如标签。
我看到我可以用属性说:
TextColor = {AppThemeBinding Dark=Black, Light=White}
但我想让目标平台为我选择合适的颜色,而不是强制它们。
实际上,这个简单的 Label(没有明确指定颜色)在 iOS 上的深色模式下会消失:
<Label Text="{this:Localize SavePassword}"
Font="Large"
HorizontalOptions="StartAndExpand"
VerticalOptions="Center"
Grid.Row="0"
Grid.Column="0"/>
Xamarin Forms 甚至可以做到这一点吗?
【问题讨论】:
标签: ios xamarin.forms