Я хотел бы применить трехмерное вращение к представлению (в частности к UILabel) в iPhone. Какой самый простой способ сделать это?
Пример кода будет высоко ценится.
Для 2D вращения используйте:
//rotate label in 45 degrees label.transform = CGAffineTransformMakeRotation( M_PI/4 );
3D-трансформации см. в этой теме :
CATransform3D _3Dt = CATransform3DMakeRotation(radians(90.0f), 1.0, 0.0, 0.0);
// flipping view along axis // this will rotate view in 3D along any axis [UIView beginAnimations:nil context:nil]; CATransform3D _3Dt = CATransform3DRotate(self.layer.transform, 3.14, 1.0, 0.0,0.0); [UIView setAnimationRepeatCount:100]; [UIView setAnimationDuration:0.08]; self.layer.transform=_3Dt; [UIView commitAnimations];
Пример Swft 3
let rotationTransform = CATransform3DRotate(myView.layer.transform, CGFloat.pi, 1, 0, 0) UIView.animate(withDuration: 0.5) { self.myView.layer.transform = rotationTransform }