I’m using a custom TipViewStyle
to modify the background and slightly adjust the layout of the Tips in my app. Everything looked great until iOS 18.4. Since updating, the layout is being compressed, and the message inside the Tip is getting truncated.
Here’s a screenshot of how it looks on iOS 18.4
and another showing how it used to look before iOS 18.4.
Here is the relevant code for the custom style:
struct CustomTipViewStyle: TipViewStyle {
func makeBody(configuration: Configuration) -> some View {
VStack(alignment: .leading, spacing: 4) {
HStack {
configuration.title?
.font(.headline)
.foregroundColor(.daBackground)
Spacer()
Button(action: { configuration.tip.invalidate(reason: .tipClosed) }) {
Image(systemName: "xmark")
.foregroundColor(.daBackground.opacity(0.3))
}
}
VStack(alignment: .leading, spacing: 8.0) {
configuration.message?
.font(.subheadline)
.foregroundColor(.daBackground.opacity(0.8))
Divider().background(.daBackground.opacity(0.3))
ForEach(configuration.actions) { action in
HStack {
Spacer()
Button(action: action.handler) {
action.label()
.foregroundStyle(.accent)
.font(.system(size: 18, weight: .bold))
}
}
}
}
}
.padding()
.background(Color.daBlack)
}
}
Has anyone else experienced this issue with TipViewStyle in iOS 18.4? Any workarounds or solutions would be appreciated! Thanks in advance!
The truncation problem can be resolved by setting a sensible idealWidth
on the message.
configuration.message?
.font(.subheadline)
.foregroundStyle(.daBackground.opacity(0.8))
.frame(idealWidth: 300) // 👈 here
Ps, the modifier .foregroundColor
is deprecated, use .foregroundStyle
instead.