Here is an example code snippet to create a button animation on tap in Swift using UIKit:
main.swift896 chars31 linesFirst, we add a target and action to the button so that when it's tapped, the tapButton method is triggered.
In the tapButton method, we use the UIView.animate method to animate the button. We set the scale transform of the button and define the animation options (in this example, we're using curveEaseInOut).
Then, we define another animation block to set the original transform of the button when the animation is completed. By using two animations, we add a slight pause in the animation before it returns to the original state, which adds a nice touch to the interaction.
gistlibby LogSnag