2010-05-11 16 views
5

मैं आईफोन में एक दृश्य (विशेष रूप से एक UILabel) पर एक 3 डी रोटेशन लागू करना चाहता हूं। ऐसा करने का सबसे आसान तरीका क्या है?आईफोन दृश्य में 3 डी रोटेशन लागू करें

एक कोड उदाहरण की सराहना की जाएगी।

+0

इस सवाल से मिलता-जुलता है: http : //stackoverflow.com/questions/347721/ uiview-perspective-transform –

+0

धन्यवाद ब्रैड। क्या आपको लगता है कि मुझे इसे हटाना चाहिए? – hpique

उत्तर

11

2 डी रोटेशन उपयोग के लिए:

//rotate label in 45 degrees 
label.transform = CGAffineTransformMakeRotation(M_PI/4); 

3 डी परिवर्तनों के लिए this thread देखें:

CATransform3D _3Dt = CATransform3DMakeRotation(radians(90.0f), 1.0, 0.0, 0.0); 
8
// 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]; 
0

Swft 3 उदाहरण

let rotationTransform = CATransform3DRotate(myView.layer.transform, CGFloat.pi, 1, 0, 0) 

UIView.animate(withDuration: 0.5) { 
    self.myView.layer.transform = rotationTransform 
} 
संबंधित मुद्दे