iOS UIKit Animation Equivalent in Android's Kotlin Animation
byAnimation is a common feature we use often in our apps. iOS SDK does provide different ways to implement. From higher-level UIKit methods to more lower Core Animation. Any UIKit based animation is internally translated into core animations. UIKit methods abstracts the layer of core animation.
Today here we will see the higher-level UIKit animation’s equivalent in Android’s Kotlin - one of the ways that Android SDK provides us. We will use ViewPropertyAnimator - a simplified and optimised way to animate properties of a View in Android. A simple example to rotate a view by certain angle for a duration and also callback implementation when animation ends.
Below is the equivalent code snippet for Android Animation in Kotlin and iOS animation on views with UIKit.
UIView.animate(withDuration: 0.15, delay: 0, options: .curveLinear) {
} completion: { finished in
}
view.animate().rotationBy(degree).setDuration(150).setInterpolator(LinearInterpolator()).setListener(object : Animator.AnimatorListener {
override fun onAnimationRepeat(animation: Animator?) {}
override fun onAnimationCancel(animation: Animator?) {}
override fun onAnimationStart(animation: Animator?) {}
override fun onAnimationEnd(animation: Animator?) {
// Your code to handle end.
}
})
You might also like: How to Send Local Video to iMessage in Swift
You might also like: AVAudioPlayer not playing any sound
You might also like: How to Get Substring With NSRange in Swift 5
You might also like: Adding two numbers in macOS x86-64 Assembly - Part 2