My application is developed using Xamarin.iOS and I need to make it accessible. We couldn't find any help to achieve large text accessibility in xamarin.iOS. I found this link which explains how to achieve it in Xamarin.Forms and this about MonoTouch. Could someone help me how to achieve Large text accessibility on Xamarin.iOS.
How can we achieve large font accessibility in Xamarin.iOS?
971 views Asked by Narender Reddy At
2
There are 2 answers
6
On
Assign one of the UIFontTextStyles to your UI elements and when the app starts the element's text size will be set based upon the UIFontTextStyle and the user's current Accessibility Larger Text setting:
var uiLabel = new UILabel(new CGRect(40, 40, 200, 40));
uiLabel.Text = "StackOverflow";
uiLabel.Font = UIFont.GetPreferredFontForTextStyle(UIFontTextStyle.Body);
View.AddSubview(uiLabel);
If you want to dynamically response to the Accessibility Larger Text changes so the user does not have to restart your app, subscribe to UIContentSizeCategoryDidChangeNotification and update your views:
NSNotificationCenter.DefaultCenter.AddObserver(
new NSString("UIContentSizeCategoryDidChangeNotification"),
(NSNotification obj) =>
{
Console.WriteLine("Update layouts/subviews/layers/etc...");
View.SetNeedsLayout();
},
null
);
MonoTouch and Xamarin.iOS are the same thing, just a different name.
It is achieved in the exact same way, where you set the
Fontproperty of yourUILabelorUITextFieldto one of the available fonts in theUIFontstatic class like so:This should automatically scale the fonts according to your Accessibility settings on iOS.