在Swift中'CGAffineTransformIdentity'不可用 [英] 'CGAffineTransformIdentity' is unavailable in Swift
本文介绍了在Swift中'CGAffineTransformIdentity'不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在尝试使某些动画适应Swift3语法时,出现此错误.
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)
})
得到了:
'CGAffineTransformIdentity'在Swift中不可用
'CGAffineTransformIdentity' is unavailable in Swift
推荐答案
找到了这个链接表示全局常量已移入静态属性,而您发现的Swift 3迁移器未能对此进行更正.",您可以将代码简单地更改为:
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
编辑
或更简单:
toView.transform = .identity
希望这对某人有帮助.
这篇关于在Swift中'CGAffineTransformIdentity'不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文