Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIToolBar with reduced alpha, want UIBarButtonItem to have alpha 1

I have a UIToolbar with the alpha set to .6. Looks great - but it leaves the buttons with an alpha of .6 as well, which is okay but not really desirable. Is there some way to independently set the alpha of a UIBarButtonItem? How would I get these to look white instead of slightly grayed out?

like image 869
Chris Roberts Avatar asked Feb 14 '11 20:02

Chris Roberts


2 Answers

When you set the alpha on a view, all subviews are composited with that same alpha value. What you can do instead of setting the alpha on the view itself is use a tint color or background color with an alpha value. This can produce similar effects, without causing all subviews to inherit the transparency.

toolbar.tintColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];

If this doesn't work and you actually need to make the view itself transparent, you will have to rework your view hierarchy so that the opaque views are not subviews. Since bar button items aren't available as standard views, its probably not going to be workable in the toolbar case.

like image 99
Blake Watters Avatar answered Nov 02 '22 19:11

Blake Watters


self.bottomToolbar.barStyle = UIBarStyleBlack;
self.bottomToolbar.translucent = YES;
self.bottomToolbar.backgroundColor = [UIColor clearColor];

View opacity set to 1 and these settings did it for me.

like image 34
Chris Roberts Avatar answered Nov 02 '22 21:11

Chris Roberts