Skip to content

Instantly share code, notes, and snippets.

@efremidze
Last active March 12, 2017 01:12
Show Gist options
  • Save efremidze/a0f3b9174e69d5945ace86d4e26c0e72 to your computer and use it in GitHub Desktop.
Save efremidze/a0f3b9174e69d5945ace86d4e26c0e72 to your computer and use it in GitHub Desktop.
CABasicAnimation with `keyPath` value set to `fromValue`
// MARK: - CABasicAnimation
extension CABasicAnimation {
/// Creates a new animation object with its `keyPath` property set to `path` and current `keyPath` value set to `fromValue`.
convenience init(keyPath path: String, layer: CALayer) {
self.init(keyPath: path)
self.fromValue = layer.presentation()?.value(forKeyPath: path)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment