ios - 如何使用变换旋转 UIView?

标签 ios iphone uiview transform core-motion

我有一个 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 所以我猜来回倾斜手机时保持水平。

最佳答案

应该是UIViewlayer的transform属性

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

关于ios - 如何使用变换旋转 UIView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23443802/

相关文章:

ios - 应用程序进入应用程序商店后,有什么方法可以更改 bundle 显示名称?

ios - UIPopoverController 在 iOS 8/Xcode 6 中没有关闭

ios - 要动态添加 UIView,或创建 UITableView? IOS

ios - View 设计未显示在 ViewController 中

iphone - Cocos2D removeChildByTag 崩溃?

swift - 带有角半径和阴影 View 的 UIView 不会在角中剪切 subview

ios - UITabBarController 在通话或个人热点期间被按下?

ios - 在 Xamarin 中加载 PlayN 声音 Assets

iphone 图像突然变为悬停图像

iphone - pARK 在 iPhone 3GS 上工作