'CGAffineTransformIdentity' is unavailable

2019-03-17 11:51发布

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

标签: swift3 xcode8
1条回答
smile是对你的礼貌
2楼-- · 2019-03-17 12:33

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

Hope this helps somebody.

查看更多
登录 后发表回答