'CGAffineTransformIdentity' is unavailable in Swift

I'm working on upgrading an app from Swift 2.0 to Swift 3.0. When arrive at the following line of code:


UIView.animate(withDuration: duration, delay: 0.0, usingSpringWithDamping: 0.9, initialSpringVelocity: 0.8, options: [], animations: {
            fromView.transform = offScreenDown toView.transform = CGAffineTransformIdentity}, completion: {finished in transitionContext.completeTransition(true)})

I received the following error without any further suggestions.


'CGAffineTransformIdentity' is unavailable in Swift


Does anyone have any suggestions on how to fix this error?

Accepted Reply

Just rewrite it as

CGAffineTransform.identity
. The global constant was moved into a static property, and the Swift 3 migrator, as you've discovered, failed to correct for that.

Replies

Just rewrite it as

CGAffineTransform.identity
. The global constant was moved into a static property, and the Swift 3 migrator, as you've discovered, failed to correct for that.

thnaks so much!!!! This newbie has soooooo much to learn 😮

My pleasure. Yeah, I've had my fair share of those "are you kidding me?" moments too. Oh, and you're not alone with that troublesome Swift 3 migrator. I've been writing Cocoa code for like five years now, and it took me several days straight to get a current project building on Xcode 8/Swift 3.