’m experiencing an issue where a Text view is unexpectedly truncated with certain font sizes (e.g., .body) on iOS 17 and later. This does not occur on iOS 16.
I’ve applied .fixedSize(horizontal: false, vertical: true) to allow the text to grow vertically, but it still doesn’t show the entire content. Depending on the text content or font size, it sometimes works, but not always.
How can I ensure the full text is displayed correctly on iOS 17+?
Here is a minimal reproducible SwiftUI example:
let sampleText1 = """
これはサンプルのテキストです、
・箇条書き1
・箇条書き2
であかさたなクロを送り、
アアを『ああああいいいい』フライパンに入れ、あかさたなです😋
"""
let sampleText2 = """
【旬|最高級】北海道産 生サンマ 釜飯
-----
Aaa iii uuu
"""
struct ContentView: View {
var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: 10) {
HStack {
MessageTextView(text: sampleText1)
.layoutPriority(100)
Spacer()
}
HStack {
MessageTextView(text: sampleText2)
.layoutPriority(100)
Spacer()
}
}
}
}
}
struct MessageTextView: View {
var text: String
var body: some View {
Text(text)
.fixedSize(horizontal: false, vertical: true)
.font(.body)
.padding(.leading, 16)
.padding(.trailing, 16)
.padding(.top, 8)
.padding(.bottom, 8)
}
}