How do I set an adaptive font size based on the Size Class?

I'm using Visual Studio on Windows. I am trying to do what is in this example:

https: // stackoverflow.com/questions/34705085/xcode-scale-font-from-iphone-to-ipad-size

But as far as I can tell, the Properties window for the Xib in the designer, doesn't have a way to set the font size based on the size class. Is there a way to do this, or do I need to just do it programmatically? I can modify the Xml for the Xib if I have to as I have done for Storyboards.

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    This issue has been confirmed at https://bugzilla.xamarin.com/show_bug.cgi?id=56977. It seems we can't use this feature at latest VS version.
    This may be a workaround for you: open this Storyboard in the XCode and set this up there, then return back to Visual Studio interface there will be a "..." button next to the font property and the font will be shown correct depending on different devices. But do not change the settings at Visual Studio designer, it will merge them to adapt all size classes.
    Also code behind will be another choice:

    if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
    {
    
    } else if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
    {
    
    }
    
Sign In or Register to comment.