如何使用转换来旋转UIView

我有一个UIView ,我正在尝试使用您可以从coremotion态度获得的音高值进行转换(旋转)。 我正在使用转换,但我不知道我的代码是正确的,因为UIView没有做任何事情。

这是我的代码被称为每秒几次。

 - (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; } 

诚实地说,我不确定如何设置这个部分(pitch + M_PI_2,1,0,0)来使得我的squar UIView的音高效果,所以当我们来回倾斜手机的时候,我会保持水平。

任何帮助,将不胜感激。

它应该是UIView layer's transform property

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

这将工作

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