ios – Button type label picture and textual content foreground coloration change at a unique time?


I’ve a query about part of my code in my customized button type. So I created a customized button type and that is what I’m returning:

return AnyView(Label {
    configuration.label
} icon: {
    icon.resizable().body(width: 30, peak: 30)
})
.labelStyle(myCustomLabelStyle())
.foregroundColor(
    configuration.isPressed ? Shade.blue : Shade.pink
)
.dynamicFont(myCustomFont())
.padding()
.body(maxWidth: .infinity, minHeight: 20)
.background(Shade.yellow)
.clipShape(Capsule())

The foregroundColor ought to change once I faucet the button, and it does change. The problem is, the icon takes a couple of extra milliseconds to return to its authentic coloration. For instance, for example the colour of the textual content and icon is pink. After I click on on the button each turn into blue, however textual content goes again to pink instantly as soon as I let go and icon(picture) goes again to pink with a really temporary(a couple of millisecond) animation. I would like each to be synced.

notes:
I do know that more often than not in button kinds we simply return configuration.label, however what I’m returning additionally works and has no points.
icon on this case is Picture(systemName: “plus”)

Leave a Reply