NEW: Start my new Ultimate Portfolio App course with a free Hacking with Swift+ trial! >>

SOLVED: Views in IPhone 11 Pro look bigger than IPhone Pro Max really need to fix the UI so they match.

Forums > SwiftUI

Hi everyone

I obbserved there is a difference in the view size look, i tried to run same code in both simulators IPhone 11 pro and IPhone 11 pro max. The problem is that if i follow how the UI looks in IPhone 11 pro max, i find that it looks bigger in IPhone 11 Pro. i know both devices have different resolutions and screen sizes but can anyone tell me how to manage this issue.

Thanks for your replies in advance.

   

Hi,

are you sure it makes sense to have the UI look exactly the same on these screens? What about older devices or even then current iPhone SE?

   

thanks for your reply @nemecek-filip, i'm using SwiftUI which works only on iOS 13 and up. old devices if they are able to upgrade they'll install others they need to buy new IPhone.

For the UI yes i need to fix the size cause i need to follow something commun between all devices, if you have any solution please let me know how to fix this problem.

Thanks

   

Hi TheWhiteSword

Is both simulator set to Physical Size (cmd+1)?

It depends on your code but I think you may have use .frame(). If you had, I will try to explain. (if you have not then ignore and give us sample code to see want you mean).

If you have a square and run on both iPhone 11 and 11 Pro Max

struct ContentView: View {
    var body: some View {
        Rectangle()
            .frame(width: 200, height: 200)
    }
}

then the square looks smaller on the bigger (the Max) screen but it an optical illusion because there is more white space between the square and the edge of screen, however the square itself is actually the same size. If you want the square to be the same distance from the edge then you have to increase the size of square when on a bigger screen

struct ContentView: View {
    let width = UIScreen.main.bounds.width - 170
    var height: CGFloat {
        width
    }

    var body: some View {
        Rectangle()
            .frame(width: width, height: height)
    }
}

This really depands on what you want to do, but as long as it look good on both eg not clipped etc then it down to design. Also have to watch when using .frame() as you may run it to going off the screen in smaller iPhones eg iPhone 12 Mini

   

Hi dear @NigelGee

Thank you so much for your reply!

You are right both views look same in real size simulators just would ask if it's possible to give different view sizes for each device means same layout but views are different in size for each specific device?

   

Hacking with Swift is sponsored by Stream

SPONSORED Check out Stream's cross-platform open source chat SDK on GitHub! Write once and deploy your app with fully featured chat UI on iOS and macOS.

Go to GitHub

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

Reply to this topic…

You need to create an account or log in to reply.

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.