Search code examples
iosscreendevicelaunchaspect

maintaining aspect ratio on launch screen


I expect there's a simple answer here. If so, sorry and thanks.

I'm trying to make my launch screen for all the different iPad and iPhone sizes. On the launch storyboard I have two UIViews, one full size for the background (backView) and one in the shape of a square (squareView). I'm trying to keep the square from stretching (i.e. I'm trying to maintain a 1:1 aspect ratio) and make it 0.75 the width of whatever device the app runs on. I know that there will be varying amounts of space below, but how can I keep the square from distorting when I switch devices? I've been researching the constraints and diddling with them for hours. I expect someone will tell me it's easy, just do ... what?


Solution

  • First, I've centered my rect horizontally and vertically Centering

    Then I've set the rect's width to x0.75 of his superview Setting WidthSetting Width multiplier

    For the final step I'm setting his ratio to 1:1 Setting ratio Setting ratio multiplier

    That's it! Final result: final result