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 2 WKInterfaceLabel
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 the WKInterfaceController
. In the animation block, change the alpha
values as required, something like
animateWithDuration(1.0) {
self.visibleLabel.setAlpha(0.0)
self.invisibleLabel.setAlpha(1.0)
}
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With