我正在使用以下代码通过SwiftUI在屏幕上显示大量数字:
return GeometryReader() { geometry in
Text(series.split(separator: ",")[self.calculator.pointsIndex])
.font(Font.system(size: round(geometry.size.height * 1.5),
weight: .light,
design: .rounded))
.minimumScaleFactor(0.2)
.scaledToFit()
.allowsTightening(true)
.background(Color.red.opacity(0.25))
}
在模拟器上看起来像这样:
在设备上看起来像这样:
我一直在绞尽脑汁,想弄清楚为什么设备上的数字这么少。有什么想法吗?
[round(geometry.size.height * UIScreen.main.scale * 1.2
在设备(和不同设备)和模拟器上给出不同的结果。