Post

Replies

Boosts

Views

Activity

Reply to Text is truncated with certain font sizes on iOS 17+, but not on iOS 16
Thank you! You’re right — the Spacer()s themselves are not strictly necessary. However, I do need to apply trailing padding and align the text to the leading edge. I tried removing the Spacer() and simplifying the layout, but the issue still reproduces with the following code: HStack { MessageTextView(text: sampleText1) .layoutPriority(100) .padding(.trailing, 20) .frame(maxWidth: .infinity) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’25
Reply to Text is truncated with certain font sizes on iOS 17+, but not on iOS 16
I’ve found a workaround that avoids the truncation issue on iOS 18 and later using the new textRenderer(_:) modifier. It ensures that all lines are rendered properly without truncation. @available(iOS 17, *) struct MyTextRenderer: TextRenderer { func draw(layout: Text.Layout, in ctx: inout GraphicsContext) { for line in layout { ctx.draw(line) } } } extension View { @ViewBuilder func avoidTextTruncationBug() -> some View { if #available(iOS 18, *) { textRenderer(MyTextRenderer()) } else { self } } } 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) .avoidTextTruncationBug() } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’25
Reply to Button Touch Not Canceled in ScrollView on Modal in SwiftUI for iOS 18
Hi Thank you for your reply. The environment I tested on below. Xcode Version: 16.0 (16A242) OS: iOS 18.0 Device: iPhone 16 Pro simulator, iPhone 12 mini
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’24
Reply to Button Touch Not Canceled in ScrollView on Modal in SwiftUI for iOS 18
I found that calling .simultaneousGesture(TapGesture()) on a Button can avoid this issue.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’24
Reply to Text is truncated with certain font sizes on iOS 17+, but not on iOS 16
Thank you! You’re right — the Spacer()s themselves are not strictly necessary. However, I do need to apply trailing padding and align the text to the leading edge. I tried removing the Spacer() and simplifying the layout, but the issue still reproduces with the following code: HStack { MessageTextView(text: sampleText1) .layoutPriority(100) .padding(.trailing, 20) .frame(maxWidth: .infinity) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’25
Reply to Text is truncated with certain font sizes on iOS 17+, but not on iOS 16
I’ve submitted feedback to Apple as well: FB17223576.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’25
Reply to Text is truncated with certain font sizes on iOS 17+, but not on iOS 16
I’ve found a workaround that avoids the truncation issue on iOS 18 and later using the new textRenderer(_:) modifier. It ensures that all lines are rendered properly without truncation. @available(iOS 17, *) struct MyTextRenderer: TextRenderer { func draw(layout: Text.Layout, in ctx: inout GraphicsContext) { for line in layout { ctx.draw(line) } } } extension View { @ViewBuilder func avoidTextTruncationBug() -> some View { if #available(iOS 18, *) { textRenderer(MyTextRenderer()) } else { self } } } 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) .avoidTextTruncationBug() } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’25