我的应用程序中有一个大尺寸标签,我已经实现了这一点,因此标签的字体重量较小:
<?xml version="1.0" encoding="utf-8"?>
<Label xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Japanese;assembly=J"
x:Class="J.Templates.WordLabel" >
<Label.FontFamily>
<OnPlatform x:TypeArguments="x:String" Android="sans-serif-thin" iOS=".SFUIText-Light" />
</Label.FontFamily>
</Label>
有谁知道如何在Android和iOS上实现具有更小权重的字体?
您可以根据自己的要求使用Google字体。来自here
现在将字体添加到Android(Assets)设置属性为AndroidAssets,将iOS(资源)设置属性添加为BundleResource。
1)将以下代码添加到App.xaml并提供字体名称(在我的案例中为OpenSans-Regular)。
<Application.Resources>
<ResourceDictionary>
<OnPlatform x:Key="fontFamilyOpenSansRegular" x:TypeArguments="x:String" iOS="OpenSans-Regular" Android="OpenSans-Regular.ttf#OpenSans-Regular" />
</ResourceDictionary>
</Application.Resources>
2)使用DynamicResource调用如下字体。
<Label Text="Test" TextColor="#1db4d9" HorizontalOptions="FillAndExpand" HorizontalTextAlignment="Center" FontFamily="{DynamicResource fontFamilyOpenSansRegular}">
它完成了。如果它适合您,请告诉我。