我以前做过这件事,但不知怎么我没办法让它起作用。我已经搜索了一点,但没有一个答案我找到解决它。
我只是试图添加一个小视图到我的self.view,并希望旋转这个添加的子视图的y轴与透视。
以下是代码:
UIView *rotatingView = [[UIView alloc] initWithFrame:(CGRect){{40.0f, 50.0f}, 50.0f, 50.0f}];
rotatingView.backgroundColor = [UIColor lightGrayColor];
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0 / -500.0;
transform = CATransform3DMakeRotation(DEGREES_RADIANS(20.0f), 0.0f, 1.0f, 0.0f);
rotatingView.layer.transform = transform;
[self.view addSubview:rotatingView];这很简单。但绝对没有任何观点。我希望看到一个“倾斜”的视图,这样它就能看到它在y轴上旋转的透视图,但没有效果。
我甚至尝试过设置zPosition和anchorPoint,但是没有任何帮助。
我有一种感觉,我只是错过了一些非常简单的东西。我以前怎么做的已经从我的脑海中溜走了。
发布于 2014-07-05 11:08:04
您正在覆盖具有旋转转换的透视图的转换。
// Define the "transform" variable here
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0 / -500.0;
// assign a new transform to it here
transform = CATransform3DMakeRotation(DEGREES_RADIANS(20.0f), 0.0f, 1.0f, 0.0f);您可能应该使用CATransform3DRotate来代替:
transform = CATransform3DRotate(transform, DEGREES_RADIANS(20.0f), 0.0f, 1.0f, 0.0f);https://stackoverflow.com/questions/24585717
复制相似问题