Reputation: 2393
I have used picker control in my app and when I'm running on iOS 11 pro device it's Title text font size shows big than it's actual font size
<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 Renderer:
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;
}
}
Output on iOS:
Upvotes: 2
Views: 543
Reputation: 12723
I have tested in my local site , even the latest version of VS , it also not works .
However , if not mind not using UIFont.FromName, there is a Solution to solve that .
You can replace it with Control.Font.WithSize(xxx)
; or UIFont.SystemFontOfSize(xxx)
to change the font size .
Code as follow :
void SetFont(BindablePicker view)
{
var fontsize = view.FontSize;
Control.Font = Control.Font.WithSize((System.nfloat)fontsize);
// or
//Control.Font = UIFont.SystemFontOfSize((System.nfloat)fontsize);
}
Upvotes: 1