TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Best way to layout views relative to screen size

Forums > SwiftUI

I have been trying to layout views relative to screen size using geometry reader. All views would be centered using midX, and their y value would be taken from .midY plus or minus an offset from a switch statement that has each device in an appropriate case.

It works fine on one device (iPhone 11 Pro Max), but when I look at it on an iPhone 8, the first 3 text views are too high. When I adjust the amount of offset in y in the switch statement, the views don't move at all.

What's the best way to accommodate every possible screen size?

2      

Yo, wanna post some code then we can possibly have a look at it.

2      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.