I tried to display the screen of the app according to the screen width, but it seems that the size of geometry differs depending on the simulator.
Is there a way to get the correct size?
Target iPad mini pixcel width: 768 geometory pixcel width: 744
Others iPhone12 mini pixcel width: 375 geometory pixcel width: 375
iPad 9.7inch pixcel width: 768 geometory pixcel width: 768
iPad 12.9inch pixcel width: 1024 geometory pixcel width: 1024
iPhone8 pixcel width: 375 geometory pixcel width: 375
Code
struct ContentView: View {
var body: some View {
GeometryReader {GeometryProxy in
Text("Hello, World!")
.padding()
.background(GeometryReader{ geometry -> Text in
// size → frame
print("******",geometry.frame(in: .global))
return Text("")
})
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Your GeometryProxy is reporting the correct size.
The iPad mini 6 has a screen resolution of 2266x1488
So in Portrait mode, the screen width (in Points) is 744.
This is narrower than the previous iPad minis, which were 768 wide.
Reference:
I raised this issue here: