47

Came across this error when trying to do adapt some animations into Swift3 syntax.

 UIView.animate(withDuration: duration, delay: 0.0, usingSpringWithDamping: 0.5, 
 initialSpringVelocity: 0.8, options: [] , animations: {
        fromView.transform = offScreenLeft

        toView.transform = CGAffineTransformIdentity

        }, completion: { finished in
            transitionContext.completeTransition(true)              
    })

and got this:

'CGAffineTransformIdentity' is unavailable in Swift

AMAN77
  • 6,218
  • 9
  • 45
  • 60

1 Answers1

128

Found this link which suggested that "The global constant was moved into a static property, and the Swift 3 migrator, as you've discovered, failed to correct for that. " and that you can simply change the code to :

 toView.transform = CGAffineTransform.identity

EDIT

or even simpler:

toView.transform = .identity
starball
  • 20,030
  • 7
  • 43
  • 238
AMAN77
  • 6,218
  • 9
  • 45
  • 60
  • 4
    Note that the type `CGAffineTransform` can be inferred by context, so you could just say `toView.transform = .identity` – Hamish Oct 12 '16 at 11:00