safe way to animate CALayer

When I was looking for a CALayer animation, I found solutions like this one:

let basicAnimation = CABasicAnimation(keyPath: "opacity")
basicAnimation.fromValue = 0
basicAnimation.toValue = 1
basicAnimation.duration = 0.3
add(basicAnimation, forKey: "opacity")

But fromValue and toValue are type of Any, and as a key we can use any string, which is not safe. Is there a better way to do so using newest Swift features?



from Recent Questions - Stack Overflow https://ift.tt/3i5Nfjm
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)