UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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.

3      

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?

3      

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

3      

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

3      

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?

3      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

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.