Anoop
Anoop

Reputation: 859

How to change Picker font size using Xamarin forms ios PickerRenderer?

For Android i was able to do it this way

protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
    base.OnElementChanged(e);
    if (e.OldElement == null && e.NewElement == null) return;
    Control.TextSize = 14f;
    Control.SetTextColor(Color.FromHex(Constants.Color.SLATE_GRAY).ToAndroid());
}

Is there any way for ios using Xamarin.Forms.Platform.ios.PickerRenderer? I could see an example in ios. link. But now sure how to convert it into Xamarin.

Upvotes: 0

Views: 943

Answers (1)

ColeX
ColeX

Reputation: 14463

By clicking 'Go to Definition' ,you can find PickerRenderer inherit ViewRenderer<Picker, UITextField>

so we just set Font on Control , refer to the following code

protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
    base.OnElementChanged(e);

    if(Control != null)
    {
        Control.TextColor = UIColor.Red;
        Control.Font = UIFont.SystemFontOfSize(30);
    }
}

Upvotes: 1

Related Questions