Iphone: make view transparent, but subviews not transparent

I have a custom UIViewController named A, and I want to add its view to another controller view (named B) as a subview. The view contains two buttons as subzones. I want to make A transparent, but the buttons in it are opaque. I want to know if there is a way to do this?

+3
source share
2 answers

As i noticed

If the view is set to opacity / alpha, all of its subzones will be applied with that opacity / alpha.

Try setting the background color of your views to [UIColor clearColor]

+4
source
viewA.backgroundColor = [UIColor clearColor];
[viewA addSubview:button1];
[viewA addSubview:button2];
+1
source

Source: https://habr.com/ru/post/1784238/


All Articles