Apple contacts app displays contact info screen with avatar and action buttons (message, call, video, mail) laid out horizontally under avatar. When user changes font size in Settings > General > Accessibility > Larger Text > Larger Accessibility Size on > one of those Accessibility fonts selected then layout changes to have those actions buttons to be laid out vertically under avatar. Individual button layout changes to have text to the right of the image (from being below the image).
What is the best approach to achieve this without completely defining new layout in code for each case. Android would allow for inflating new layout for each case, but in iOS this presents stack of problems as outlined in Best way to change UIViewController view NIB programmatically. Other option of creating additional ViewControllers seems extreme as well: Easiest way to support multiple orientations? How do I load a custom NIB when the application is in Landscape?
I can correctly detect when font sizes are in Accessibility Category and flip axis of UIStack that contains action buttons, but short of changing layout programmatically I am stuck there.
You might find answers in the
WWDC 2017 : Building Apps with Dynamic Type
video whose content is perfectly summarized here.When you detect that an accessibility size is concerned, you should adapt your constraints in the
traitCollectionDidChange
method of theUITraitEnvironment
protocol (iOS 11): take a look at the example section where the questionHow can I change items position to adapt text enlargement
is well explained.