好的,这很奇怪......
func closePageCell(cell : BookPageCell) {
var transform = CATransform3DIdentity
if cell.layer.anchorPoint.x == 0 {
transform = CATransform3DRotate(transform, CGFloat(0), 0, 1, 0)
transform = CATransform3DTranslate(transform, -0.7 * cell.layer.bounds.width / 2, 0, 0)
transform = CATransform3DScale(transform, 0.7, 0.7, 1)
}
else {
transform = CATransform3DRotate(transform, CGFloat(-M_PI), 0, 1, 0)
transform = CATransform3DTranslate(transform, 0.7 * cell.layer.bounds.width / 2, 0, 0)
transform = CATransform3DScale(transform, 0.7, 0.7, 1)
}
cell.layer.transform = transform
}
转换在这里连接,但语法是' ='
当然' ='替换变换。为什么这有用?!
答案 0 :(得分:5)
CATransform3Dxxx将转换作为您自己进入的参数,并将其返回。因此,每次调用该方法时,它都会构建转换,有效地将它们连接在一起。
如果您使用transform
替换参数中的CATransform3DIdentity
,则会出现您期望的行为