我有一个UIView
,我想使用coremotion attitude获取的pitch值来对其进行转换(旋转)。我正在使用transform,但我不确定我的代码是否正确,因为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),以使俯仰影响我的正方形UIView
,因此当您前后倾斜手机时,它会保持水平。