我试图设置一个uiview的图层作为用于渲染iPhone模型屏幕(Yep,trippy:P)的材质的内容. iPhone屏幕的UV映射设置为0到1,因此在将纹理/图层映射到纹素之后不会出现任何问题.
所以,而不是让这个层在iPhone上显示出来,与左图像相同,相反,我把这个渲染到iPhone上像右图
正确渲染错误的渲染
还要注意的是,当我设置一个断点并调试实际的iPhone节点并在Xcode中查看它时,会显示一个完全不同的渲染,并且当我继续执行时,该层被半固定:
现在…如何解决这个问题?我试过玩漫漫的内容变换矩阵,但没有任何修改.我也尝试将UIView的大小调整为256×256(因为UV似乎是256×256,如搅拌机中所示 – 3D建模包),但是并没有修复任何东西.
这是图层的代码:
UIView *screen = [[UIView alloc] initWithFrame:self.view.bounds]; screen.backgroundColor = [UIColor redColor]; UIView *temp = [[UIView alloc] initWithFrame:CGRectMake(0,screen.bounds.size.width,60)]; temp.backgroundColor = [UIColor colorWithRed:0 green:(112.f/255.f) blue:(235.f/255.f) alpha:1]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectInset(temp.bounds,40,0)]; label.frame = CGRectOffset(label.frame,0); label.textColor = [UIColor colorWithRed:0 green:(48.f/255.f) blue:(84.f/255.f) alpha:1]; label.text = @"Select Track"; label.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:30]; label.minimumScaleFactor = 0.001; label.adjustsFontSizeToFitWidth = YES; label.lineBreakMode = NSLineBreakByClipping; [temp addSubview:label]; UIView *separator = [[UIView alloc] initWithFrame:CGRectMake(0,temp.bounds.size.height - 2,temp.bounds.size.width,2)]; separator.backgroundColor = [UIColor colorWithRed:0 green:(48.f/255.f) blue:(84.f/255.f) alpha:1]; [temp addSubview:separator]; [screen addSubview:temp]; screen.layer.contentsGravity = kCAGravityCenter;
编辑
甚至更严厉的是,如果我使用以下方式捕获视图的UIImage:
- (UIImage *) imageWithView:(UIView *)view { UIGraphicsBeginImageContextWithOptions(view.bounds.size,view.opaque,0.0); [view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage * img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return img; }
并使用它作为弥漫的内容…一切工作完全正常吗?这是真的很奇怪和令人沮丧,因为图像的大小是完全一样的uiview的…
编辑2
我最终只是使用视图的图像作为纹理,这使得事情比我需要的更加静态.我不会将此设为答案,因为即使在很长一段时间内,我仍然会等待正确解决这个问题.所以,如果你有一个答案,这个主题已经打开了很长时间,请碰到它,如果可以的话.这部分的文件太差了.
解决方法
SceneKit cannot use a layer that is already being displayed elsewhere (for example,the backing layer of a
UIView
object).
这表明如果您想为您的材料制作动画内容,则您可以使用完全基于自己或者SpriteKit使用的核心动画.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。