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()
}
}
2
0
1.2k