ios - Z 轴支持查看 UIView

标签 ios cocos3d

我想在 Z 轴上从主相机 View 向前放置一个 UIView。我添加了如下代码。我正在尝试使用 CATransform3DTranslate,但是 JAPanoView(它的一个 uiview)没有显示在 Z 轴值中,提到要提前到相机 View 。有人可以建议,我该如何实现?

    -(void) initializeScene {

    // Create the camera, place it back a bit, and add it to the scene
    CC3Camera* cam = [CC3Camera nodeWithName: @"Camera"];
    cam.location = cc3v( 0.0, 0.0, 12.0 );
    [self addChild: cam];

    // Create a light, place it back and to the left at a specific
    // position (not just directional lighting), and add it to the scene
    CC3Light* lamp = [CC3Light nodeWithName: @"Lamp"];
    lamp.location = cc3v( 0.0, 40.0, 0.0 );
    lamp.isDirectionalOnly = NO;
    [cam addChild: lamp];

    // JAPanoView IS AN UIVIEW
    JAPanoView *panoView=[[JAPanoView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
    //self.view=panoView;
    panoView.delegate=self;
    [panoView setFrontImage:[UIImage imageNamed:@"Home_front.png"] rightImage:[UIImage imageNamed:@"Home_right.png"] backImage:[UIImage imageNamed:@"Home_back.png"] leftImage:[UIImage imageNamed:@"Home_left.png"] topImage:[UIImage imageNamed:@"Home_up.png"] bottomImage:[UIImage imageNamed:@"Home_down.png"]];

    CATransform3D _3Dt = CATransform3DIdentity;
    _3Dt = CATransform3DTranslate(_3Dt, 0, 0, -30);
    panoView.layer.transform = _3Dt;

    [[[CCDirector sharedDirector] openGLView] addSubview:panoView];

    // Create OpenGL ES buffers for the vertex arrays to keep things fast and efficient,
    // and to save memory, release the vertex data in main memory because it is now redundant.
    [self createGLBuffers];
    [self releaseRedundantData];
}

最佳答案

UIView 的 z 顺序是它们在其父 View 的 subview 属性中的顺序。要将 subview 放在另一个前面,您可以使用用户以正确的顺序简单地添加 subview ,按此顺序将它们放在 XIB 文件中或使用 bringSubviewToFront。

关于ios - Z 轴支持查看 UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18397565/

相关文章:

java - iOS + appium java 客户端 : Long press TouchAction does not work?

iphone - iOS 应用程序如何在后台无限期地保持 TCP 连接?

ios - Cocos3d : Set CC3Scene backdrop to transparent

iphone - 用于iphone开发的Cocos 3D POD文件格式

iphone - 在 iOS 5.1 中禁用自动屏幕锁定

ios - AVSpeechSynthesizer 不适用于 iOS10

ios - Facebook App邀请不起作用

ios - 如何为已经构建的 native iOS 应用程序制作一个简单的 3d 对象查看器组件?

iphone - Cocos3d 和增强现实