Add UIview (From Xib) with Transparency to Scenekit

How to render a UIView with transparent background on an SCNPlane in ARKit?

Try setting your view's isOpaque property to false:

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

iphone: How to make a Transparency mask over the UIVIEW

Have a look at iPhone - Create a semi transparent rectangle with text I think you are having the same problem.

Is there any other way to display UIView into ARKit?

From Apples docs on SCNMaterialProperty.contents:

SceneKit cannot use a layer that is already being displayed elsewhere (for example, the backing layer of a
UIView
object)

Personally the easiest way of displaying information on a plane is using a SpriteKit Scene.

iPhone custom UIView with partial transparency

Yes, this is possible. You can, for instance, use an image with Alpha channel in your view. If you want something like cardboard cutouts, you will probably create images for the cutouts anyway. Just have the head-holes transparent (and use transparent backgroundColor for the UIImageView).

There is nothing wrong with using a composite view to achieve the desired outcome, though. If you plan to reuse your view often, make it a UIView subclass.

Another way is using CALayer's mask property.

Adjust opacity on button inside UIView with opacity at 0.5

The problem with setting the opacity on the view is that all of the subviews will be affected by the same opacity.

So if you have a view with opacity 0.5 then any subviews will have a maximum effective opacity of 0.5.

To fix this you can give the view an opacity of 1.0 but then set the background color like...

view.backgroundColor = Color.white.withAlphaComponent(0.5)

This will still allow the subviews to have an opacity of 1.0.

Setting alpha on UIView sets the alpha on its subviews which should not happen

I think this is a bug in the documentation. You should file it at bugreport.apple.com.

Everything I can see after a bit of quick research suggests what you are seeing is how it always has behaved, and my own testing shows it too.

The alpha of a view is applied to all subviews.

Perhaps all you need is [[UIColor blackColor] colorWithAlphaComponent:0.5] but if not you will need to make the view a sibling instead of a child.



Related Topics



Leave a reply



Submit