I am creating a launch screen that has a centered image. I want the image to be 0.7 of the width in portrait orientation and 0.7 of the height in landscape orientation, so the image is the same size in both orientations, but relative to device size. It would be smaller on iPhones and larger on iPads, while supporting both orientations on iPad.
I can do one of those constraints but not both. For example, if I make it 0.7 of the width in portrait then it looks good in portrait but then oversized in landscape, and vice versa.
How do I create such autolayout purely in interface builder? (I'm assuming launch screens must only use IB.)
The trick is to add two sets of proportional width and height constraints...
First:
Then:
So our constraints are saying:
Priority: 750
(High, but not Required)Priority: 1000
(Required)Priority: 1000
(Required)Here's how it looks in the Document Outline pane:
and here's what we get for iPad 9.7":
and iPhone 11: