UIView animations creates CAAnimations underlying.

Updated
Jan 10, 2021 9:53 AM
Created
Jan 10, 2021 9:52 AM
Tags
Keywords

import UIKit

let view = UIView()

let animatior = UIViewPropertyAnimator(duration: 0.3, dampingRatio: 1) {
  view.alpha = 0
  view.backgroundColor = .black
}

animatior.startAnimation()

let anims = view.layer.animationKeys()!.compactMap {
  view.layer.animation(forKey: $0)
}

anims.forEach {
  print("")
  debugPrint($0)
}

<CASpringAnimation:0x6000017d9440; toValue = 0.0; removedOnCompletion = 0; delegate = <UIViewAnimationState: 0x154104580>; fillMode = both; duration = 0.3; fromValue = 1; velocity = 0; damping = 61.5561; stiffness = 947.288; mass = 1; timingFunction = linear; keyPath = opacity>

<CABasicAnimation:0x6000017d9580; removedOnCompletion = 0; delegate = <UIViewAnimationState: 0x154104580>; fillMode = both; timingFunction = easeInEaseOut; duration = 0.3; toValue = 100; fromValue = 0.0; keyPath = uiFractionalProgress>

<CASpringAnimation:0x6000017d96c0; toValue = <CGColor 0x6000034dc870> [<CGColorSpace 0x6000033c8300> (kCGColorSpaceICCBased; kCGColorSpaceModelMonochrome; Generic Gray Gamma 2.2 Profile; extended range)] ( 0 1 ); removedOnCompletion = 0; delegate = <UIViewAnimationState: 0x154104580>; fillMode = both; duration = 0.3; fromValue = (null); velocity = 0; damping = 61.5561; stiffness = 947.288; mass = 1; timingFunction = linear; keyPath = backgroundColor>