Entry Font Size on iOS

Download Sample Download the sample

This iOS platform-specific is used to scale the font size of an Entry to ensure that the inputted text fits in the control. It's consumed in XAML by setting the Entry.AdjustsFontSizeToFitWidth attached property to a boolean value:

<ContentPage ...
    <StackLayout Margin="20">
        <Entry x:Name="entry"
               Placeholder="Enter text here to see the font size change"
               ios:Entry.AdjustsFontSizeToFitWidth="true" />

Alternatively, it can be consumed from C# using the fluent API:

using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;


The Entry.On<iOS> method specifies that this platform-specific will only run on iOS. The Entry.EnableAdjustsFontSizeToFitWidth method, in the Xamarin.Forms.PlatformConfiguration.iOSSpecific namespace, is used to scale the font size of the inputted text to ensure that it fits in the Entry. In addition, the Entry class in the Xamarin.Forms.PlatformConfiguration.iOSSpecific namespace also has a DisableAdjustsFontSizeToFitWidth method that disables this platform-specific, and a SetAdjustsFontSizeToFitWidth method which can be used to toggle font size scaling by calling the AdjustsFontSizeToFitWidth method:


The result is that the font size of the Entry is scaled to ensure that the inputted text fits in the control:

Adjust Entry Font Size Platform-Specific