I am working on an apple watch application. In the application, I have a view where the user may swipe left and right between 3 given results. I am using WKInterfaceLabel to show result information. On each swipe, labels are updated with new text.
View screenshot:
I want to animate the change of text on swipe. How can I do this?
Any help provided will be appreciated. Thanks!
This is not very elegant, but it should work:
You can fade out the contents of a
WKInterfaceLabel
, and fade in another label in its place. So, place 2WKInterfaceLabel
objects at the same place. One of them is visible (alpha
= 1.0) and the other invisible (alpha
= 0.0).When you swipe, determine the new value that should be shown, and set it to the invisible label.
Then, animate the transition using the function
animate(withDuration:animations:)
of theWKInterfaceController
. In the animation block, change thealpha
values as required, something likeHope this helps!