I’m using the new .glassEffect(.interactive()) API in SwiftUI (iOS 26), and I want to change the tint color based on state.
However, when I conditionally change the tint using a ternary, the interactive glass animation gets interrupted midway (the glass balloons and then instantly shrinks).
Here’s the example:
.overlay(alignment: .topTrailing) {
Button(action: { saved.toggle() }) {
Image(saved ? "bookmark" : "bookmark.outline")
.resizable()
.scaledToFit()
.frame(width: 14, height: 14)
.foregroundStyle(.white)
.padding(8)
}
.glassEffect(
.clear
.tint(saved ? overlayCol : overlayCol.opacity(0.1))
.interactive()
)
.padding(.top, 8)
.padding(.trailing, 8)
}
What’s the correct way to update the tint of an interactive glass effect without breaking or restarting the animation? In native apps like the Phone app, when you filter calls, the button changes from no tint to a blue tint (but it’s a little different since it seems like the blue tint is an embedded circle inside the button itself). The next best example I can think of is in the Reminders app when you open a list, the + button in the bottom toolbar changes from blue to orange.