本文介绍了如何使用变换旋转UIView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 UIView
,我正尝试使用可以从coremotion姿态获得的俯仰值进行变换(旋转).我正在使用转换,但是我不确定我的代码是否正确,因为 UIView
没有执行任何操作.
I have a UIView
which I am trying to transform (rotate) using the pitch value you can get from coremotion attitude. I am using transform however I am not sure my code is correct as the UIView
is not doing anything.
这是我的代码,每秒被调用几次.
This is my code its being 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;
}
我不确定如何设置此部分(间距+ M_PI_2、1、0、0),以使间距影响我的正方形 UIView
,所以我猜来回倾斜手机时保持水平.
I am not sure how to set this part (pitch + M_PI_2, 1, 0, 0) to make the pitch affect my square UIView
so it would I guess stay level as you tilt the phone back and forth.
推荐答案
它应该是 UIView
wapaA.layer.transform = CATransform3DMakeRotation(pitch + M_PI_2, 1, 0, 0);
这篇关于如何使用变换旋转UIView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!