SwiftUI:minimumScaleFactor 不处理特殊字符,如 í 或 ý



我将字体设置为200,将minimumScaleFactor设置为0.01。使用英文字符时,一切都可以完美地缩放。但当我尝试使用ýúáí或包含这些字符的句子时,缩放比例是不正确的。更奇怪的是,有时缩放在"纵向"模式下看起来很好,而在"横向"模式下则不然。

我正在使用自定义字体,但我没有找到使用.largetFont或其他方法的方法。除了我正在努力实现的目标之外,还有其他方式吗?

import SwiftUI
struct TextScale: View {
var body: some View {
GeometryReader { geo in
VStack(spacing: 0) {
Text("ýúáí!")
.font(.custom("Verdana-Bold", size: 200))
.lineLimit(1)
.minimumScaleFactor(0.01)
.foregroundColor(Color.white)
.frame(width: geo.size.width, height: geo.size.height/5, alignment: .center)
.background(Color.green)
Image(systemName: "camera")
.resizable()
.scaledToFit()
.frame(width: geo.size.width, height: 3*geo.size.height/5)
.background(Color.blue)
HStack {
Image(systemName: "camera")
.resizable()
.scaledToFit()
}
.frame(width: geo.size.width, height: geo.size.height/5)
//.padding(.bottom)
.background(Color.orange)
}
.background(Color.gray)
}
}
}
struct TextScale_Previews: PreviewProvider {
static var previews: some View {
TextScale()
}
}

更改布局策略。。。尝试

struct ContentView: View {
var body: some View {
GeometryReader { geo in
VStack(spacing: 0) {
Text("yáž!")
.font(.custom("Verdana-Bold", size: geo.size.height/9))
.lineLimit(1)
.foregroundColor(Color.white)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.green)
Image(systemName: "camera")
.resizable()
.scaledToFit()
.frame(width: geo.size.width, height: 3*geo.size.height/5)
.background(Color.blue)
HStack {
Image(systemName: "camera")
.resizable()
.scaledToFit()
}
.frame(width: geo.size.width, height: geo.size.height/5)
//.padding(.bottom)
.background(Color.orange)
}//.edgesIgnoringSafeArea(.all)
.background(Color.gray)
}
}
}

最新更新