Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Not having child alpha be influence by parent view

I have placed a button in a view and I want the view to be translucent, but the button to be solid. The button is taking on whatever alpha the the view has. How do I get the button to have it's own alpha?

Thanks in advance!

How are you changing the alpha of the view?

I am changing the alpha in the storyboard attributes inspector.

1 Answer

Gabe Nadel
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Gabe Nadel
Treehouse Guest Teacher

Well, the items in a view WILL be subject to the alpha of their parent view, that's the way it works, and for good reason. However, perhaps you can fake this out a bit:

Make your parent view fully opaque, alpha =1, but set it's background color to clear. Then, set your button however you want. If you want your view to appear translucent (but not completely transparent) then create a new UIView inside of the parent UIView (of the same size as the parent view) and give THAT UIView the alpha and background color you want users to see as "translucent".