简体   繁体   中英

How to combine 2 3D Rotations without canceling each other?

I have a view which I want to rotate in two different directions.

The first is:

arrowImageView.layer.transform = CATransform3DMakeRotation(rotationAngle, 0, 0, 1)

and the second is:

arrowImageView.layer.transform = CATransform3DMakeRotation(pitch, 1, 0, 0)

How can I combine these two rotations without canceling one out?

You combine 3D transformations with CATransform3DConcat() :

let t1 = CATransform3DMakeRotation(rotationAngle, 0, 0, 1)
let t2 = CATransform3DMakeRotation(pitch, 1, 0, 0)
arrowImageView.layer.transform = CATransform3DConcat(t1, t2)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM