如何在xamarin.forms中更改选择器标题字体大小?

问题描述 投票:1回答:1

[我在应用中使用了选择器控件,当我在iOS 11专业版设备上运行时,标题文本的字体大小比实际字体大]]

<CustomControl:BindablePicker x:Name="pick"
              Font="lato-regular" 
              FontSize="12" 
              Title="{Binding Placeholder}" 
              ItemsSource="{Binding Season}" 
              SelectedItem="{Binding SelectedOption, Mode=TwoWay}" 
              HorizontalOptions="FillAndExpand"
              BorderWidth="1" />

iOS渲染器:

protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
    var view = (BindablePicker)Element;
    if (view != null && Control != null)
    {
        SetFont(view);
    }
}

void SetFont(BindablePicker view)
{
     var fontsize = view.FontSize;
     var font = UIKit.UIFont.FromName("lato-regular", (System.nfloat)fontsize);
     if (font != null)
     {
         Control.Font = UIFont.SystemFontOfSize((System.nfloat)fontsize);
         Control.Font = font;
     }
}

iOS上的输出:

enter image description here

我在我的应用中使用了选择器控件,当我在iOS 11专业版设备上运行时,标题文本字体大小显示为大于其实际字体大小

c# xamarin xamarin.forms xamarin.android xamarin.ios
1个回答
0
投票

iOS中Picker的标题文本不是Control

© www.soinside.com 2019 - 2024. All rights reserved.