SwiftUi在设备上缩放文本的方式不同

问题描述 投票:0回答:1

我正在使用以下代码通过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))
        }

在模拟器上看起来像这样:

enter image description here

在设备上看起来像这样:

enter image description here

我一直在绞尽脑汁,想弄清楚为什么设备上的数字这么少。有什么想法吗?

swiftui
1个回答
0
投票

[round(geometry.size.height * UIScreen.main.scale * 1.2在设备(和不同设备)和模拟器上给出不同的结果。

© www.soinside.com 2019 - 2024. All rights reserved.