How to rotate a UIView using transform

I have a UIView that I am trying to convert (rotate) using the pitch value that you can get from the core. I use the transform, however, I'm not sure if my code is correct, as the UIView does nothing.

this is my code that gets called several times per second.

 - (void)setLabelValueRoll:(double)roll pitch:(double)pitch yaw:(double)yaw { self.yLabel.text = [NSString stringWithFormat:@"pitch: %f", pitch]; CATransform3D transform; transform = CATransform3DMakeRotation(pitch + M_PI_2, 1, 0, 0); self.wapaA.layer.sublayerTransform = transform; } 

Honestly, I'm not sure how to set this part (pitch + M_PI_2, 1, 0, 0) to make the pitch effect my UIView square, so I would suggest that the stop level is when you tilt the phone back and forth.

Any help would be appreciated.

+4
source share
2 answers

It should be a layer transform property from UIView

 wapaA.layer.transform = CATransform3DMakeRotation(pitch + M_PI_2, 1, 0, 0); 
+2
source

It will work

 float degrees = 20; //the value in degrees view.transform = CGAffineTransformMakeRotation(degrees * M_PI/180); 
0
source

Source: https://habr.com/ru/post/1269545/


All Articles