return config;
}
#endregion
+
+ #region EnableAccessibilityScalingForNamedFontSizes
+ public static readonly BindableProperty EnableAccessibilityScalingForNamedFontSizesProperty = BindableProperty.Create("EnableAccessibilityScalingForNamedFontSizes", typeof(bool), typeof(Application), true);
+
+ public static bool GetEnableAccessibilityScalingForNamedFontSizes(BindableObject element)
+ {
+ return (bool)element.GetValue(EnableAccessibilityScalingForNamedFontSizesProperty);
+ }
+
+ public static void SetEnableAccessibilityScalingForNamedFontSizes(BindableObject element, bool value)
+ {
+ element.SetValue(EnableAccessibilityScalingForNamedFontSizesProperty, value);
+ }
+
+ public static bool GetEnableAccessibilityScalingForNamedFontSizes(this IPlatformElementConfiguration<iOS, FormsElement> config)
+ {
+ return GetEnableAccessibilityScalingForNamedFontSizes(config.Element);
+ }
+
+ public static IPlatformElementConfiguration<iOS, FormsElement> SetEnableAccessibilityScalingForNamedFontSizes(this IPlatformElementConfiguration<iOS, FormsElement> config, bool value)
+ {
+ SetEnableAccessibilityScalingForNamedFontSizes(config.Element, value);
+ return config;
+ }
+ #endregion
}
}
using System.Threading.Tasks;
using Xamarin.Forms.Internals;
using Foundation;
+using Xamarin.Forms.PlatformConfiguration;
+using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
+
#if __MOBILE__
using UIKit;
using Xamarin.Forms.Platform.iOS;
using AppKit;
using Xamarin.Forms.Platform.MacOS;
using TNativeView = AppKit.NSView;
-
#endif
namespace Xamarin.Forms
class IOSPlatformServices : IPlatformServices
{
-
readonly double _fontScalingFactor = 1;
public IOSPlatformServices()
{
{
// We make these up anyway, so new sizes didn't really change
// iOS docs say default button font size is 15, default label font size is 17 so we use those as the defaults.
+ var scalingFactor = _fontScalingFactor;
+
+ if (Application.Current?.On<iOS>().GetEnableAccessibilityScalingForNamedFontSizes() == false)
+ {
+ scalingFactor = 1;
+ }
+
switch (size)
{
//We multiply the fonts by the scale factor, and cast to an int, to make them whole numbers.
case NamedSize.Default:
- return (int)((typeof(Button).IsAssignableFrom(targetElementType) ? 15 : 17) * _fontScalingFactor);
+ return (int)((typeof(Button).IsAssignableFrom(targetElementType) ? 15 : 17) * scalingFactor);
case NamedSize.Micro:
- return (int)(12 * _fontScalingFactor);
+ return (int)(12 * scalingFactor);
case NamedSize.Small:
- return (int)(14 * _fontScalingFactor);
+ return (int)(14 * scalingFactor);
case NamedSize.Medium:
- return (int)(17 * _fontScalingFactor);
+ return (int)(17 * scalingFactor);
case NamedSize.Large:
- return (int)(22 * _fontScalingFactor);
+ return (int)(22 * scalingFactor);
#if __IOS__
case NamedSize.Body:
return (double)UIFont.PreferredBody.PointSize;