我尝试用自己的锚点旋转一个90度角的uiview (高度和宽度为100)。更改锚点后,我转换我的视图,以便两个更改相互抵消。
当我使用(Double.pi)旋转视图时,它会像预期的那样产生动画效果,但当我更改为(Double.pi/2)时,视图会向上跳跃。
testView.layer.anchorPoint = CGPoint(x: 0.5, y: 1)
testView.layer.transform = CATransform3DMakeTranslation(0, -50, 0)
UIView.animate(withDuration: 2.3, delay: 0, options: .curveLinear, animations: { () -> Void in
var allTransofrom = self.testView.layer.transform
var c3d = CATransform3DIdentity
c3d.m34 = 2.5 / (2000)
let rot = CATransform3DRotate(c3d, CGFloat(Double.pi/2), 1, 0, 0)
allTransofrom = CATransform3DConcat(allTransofrom, rot)
self.testView.layer.transform = allTransofrom
}, completion: {(finished) in
} )完整代码here
https://stackoverflow.com/questions/51385107
复制相似问题