如何在ARKit中的SCNPlane上呈现具有透明背景的UIVi

如何在ARKit中的SCNPlane上呈现具有透明背景的UIVi

本文介绍了如何在ARKit中的SCNPlane上呈现具有透明背景的UIView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的UIView具有UIColor.clear背景.我正在从情节提要中实例化View Controller.

My UIView has a UIColor.clear background. I am instantiating the View Controller from a storyboard.

当我将SCNPlane几何的漫反射内容设置为视图控制器的视图时,透明"背景在平面上显示为纯白色.这是我的设置方式

When I set SCNPlane geometry's diffuse contents to the viewcontroller's view, the Transparent background appears solid white on the plane.here is how I set it

let material = SCNMaterial()
material.diffuse.contents = viewController.view
planeGeometry.materials = [material]

我可以看到视图,只是背景不是透明的.

I can see the view, just the background is not transparent.

我在其他Stack溢出帖子上看到了建议,他们在这里建议尝试

I saw suggestion on other Stack overflow posts where they suggested to try this

material.diffuse.contents = viewController.view.layer

这有效,并且飞机渲染了透明胶片,但是视图不再是交互式的.

This works and the the plane renders the transparencies, but then the view is not interactive anymore.

在平面上渲染视图时,是否可以保留交互性和透明度?

Is there a way that I can retain the interactivity and the transparency when the view is rendered on the plane?

推荐答案

尝试设置视图的将isOpaque 属性设置为false:

Try setting your view's isOpaque property to false:

let material = SCNMaterial()
viewController.view.isOpaque = false
material.diffuse.contents = viewController.view
planeGeometry.materials = [material]

这篇关于如何在ARKit中的SCNPlane上呈现具有透明背景的UIView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 22:30