I can enable fonts for Label, entry, etc(Xamarin.Forms UI fields) like this...
<Style TargetType="Label">
<Setter Property="FontFamily">
<Setter.Value>
<OnPlatform x:TypeArguments="x:String">
<On Platform="iOS" Value="Montserrat_Regular" />
<On Platform="Android" Value="Montserrat_Regular.ttf#Montserrat_Regular" />
</OnPlatform>
</Setter.Value>
</Setter>
</Style>
But it doesn't apply font for title & content of dialog boxes, list in pickers n many more places like that(Internal iOS UI fields).
I override the default font of android to achieve the above issue, but the problem is with iOS, I can't find any solution for it in C#. There are many solutions present in objective-c & swift.
Can someone help me convert these codes or provide any other solution?
EDIT -
Dialog Boxes are Device Specific, Xamarin.Forms code won't work individually on it.
iOS Dialog box -
Device.BeginInvokeOnMainThread( () =>
{
UIAlertController alert = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert);
alert.AddAction(UIAlertAction.Create(cancel, UIAlertActionStyle.Cancel, a => task.SetResult(false)));
alert.AddAction(UIAlertAction.Create(ok, UIAlertActionStyle.Default, a => task.SetResult(true)));
UIViewController vc = GetViewController(UIApplication.SharedApplication.KeyWindow.RootViewController);
if (TargetIdiom.Tablet == Device.Idiom)
{
vc.ModalPresentationStyle = UIModalPresentationStyle.Popover;
}
vc.PresentModalViewController(alert, true);
});
Android Dialog box with fix for font -
Device.BeginInvokeOnMainThread( () =>
{
AlertDialog dialog = new AlertDialog.Builder(Forms.Context, Resource.Style.Base_Animation_AppCompat_Tooltip).SetTitle(title).SetMessage(content).SetPositiveButton(ok, delegate { task.SetResult(true); })
.SetNegativeButton(cancel, delegate { task.SetResult(false); }).Show();
TextView textView = (TextView)dialog.FindViewById(Android.Resource.Id.Message);
textView.SetTypeface(Typeface.CreateFromAsset(Forms.Context.Assets, "Montserrat_Regular.ttf"), TypefaceStyle.Normal);
var _buttonOK = (Button)dialog.FindViewById(Android.Resource.Id.Button1);
_buttonOK.SetTypeface(Typeface.CreateFromAsset(Forms.Context.Assets, "Montserrat_Regular.ttf"), TypefaceStyle.Normal);
var _buttonCancel = (Button)dialog.FindViewById(Android.Resource.Id.Button2);
_buttonCancel.SetTypeface(Typeface.CreateFromAsset(Forms.Context.Assets, "Montserrat_Regular.ttf"), TypefaceStyle.Normal);
});