Apple documentation (https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreAnimation_guide/AdvancedAnimationTricks/AdvancedAnimationTricks.html) have this sample:
CATransition* transition = [CATransition animation];
...
But when I did it in Swift:
let transition = CATransition.animation()
I got an error "animation()' is unavailable: use object construction 'CAAnimation()'" - is this deprecated or? If yes, what's the new way of doing transition?
In Objective-C [CAAnimation animation]
is a convenience method for:
[[[CAAnimation alloc] init] autorelease]
CATransition
inherits CAAnimation
and therefore inherits the convenience constructor.
In Swift, this kind of initialization is gone, and you can create the CATransition
object using the default constructor.
Try let transition = CATransition()
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