这两天在写一个效果,就需要用到CATransform3DMakeRotation旋转180度
于是有了下面的代码
UIView.animate(withDuration: 2, animations: {
imageView.layer.transform = CATransform3DMakeRotation(.pi, 0, 0, 1)// 旋转
}) { (finished) in
imageView.removeFromSuperview()
}
可是发现无论如何都是顺时针旋转。。
查阅了相关资料发现CATransform3DMakeRotation是按最短路径来选择的。。
于是这样就可以解决了
UIView.animate(withDuration: 2, animations: {
whiteImageView.layer.transform = CATransform3DMakeRotation(.pi + 0.01, 0, 0, 1)// 旋转
}) { (finished) in
whiteImageView.removeFromSuperview()
}
原理就是多了0.01的距离嘛
网友评论