Xamarin形成iOS和Android非常轻薄的字体

Xamarin形成iOS和Android非常轻薄的字体,xamarin,xamarin.forms,Xamarin,Xamarin.forms,我的应用程序中有一个大尺寸标签,我已经实现了这一点,以便标签的字体重量更小: <?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;ass

我的应用程序中有一个大尺寸标签,我已经实现了这一点,以便标签的字体重量更小:

<?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上实现一种重量甚至很小的字体吗?

你可以根据自己的要求使用谷歌字体。从

现在将字体添加到Android(资产)集合属性为AndroidAssets和iOS(资源)集合属性为BundleResource

1) 将下面的代码添加到App.xaml并提供字体名称(在我的例子中是OpenSans Regular)


2) 使用DynamicSource调用字体,如下所示

<Label Text="Test" TextColor="#1db4d9" HorizontalOptions="FillAndExpand" HorizontalTextAlignment="Center" FontFamily="{DynamicResource fontFamilyOpenSansRegular}">

一切都结束了。
让我知道它是否对您有效。

对于iOS,您需要做的另一件事是在Info.plist中添加一个条目

原始条目是:

<key>UIAppFonts</key>
<array>
    <string>fontawesome.ttf</string>
    <string>Signika-Light.ttf</string>
    <string>ionicons.ttf</string>
</array>
UIAppFonts
font.ttf
Signika-Light.ttf
ionicons.ttf

您可以参考这一点,如果使用系统字体,我还需要这样做吗?我想是的-如果是您添加到参考资料中的字体。
<key>UIAppFonts</key>
<array>
    <string>fontawesome.ttf</string>
    <string>Signika-Light.ttf</string>
    <string>ionicons.ttf</string>
</array>