我有一个 UIView
,我正在尝试使用您可以从 coremotion attitude 获得的音高值来转换(旋转)它。我正在使用转换,但是我不确定我的代码是否正确,因为 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) 以使音调影响我的方 block UIView
所以我猜来回倾斜手机时保持水平。
最佳答案
应该是UIView
的layer的transform属性
wapaA.layer.transform = CATransform3DMakeRotation(pitch + M_PI_2, 1, 0, 0);
关于ios - 如何使用变换旋转 UIView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23443802/