How to make UIToolbar have a Clear Background?

Kyle Rosenbluth picture Kyle Rosenbluth · Aug 21, 2012 · Viewed 11.2k times · Source

I have a UIToolbar that has a white tint, with a bar button item, followed by some flexible space, followed by another bar button item. I would like to make the toolbar completely clear so that I can see what is under the flexible space (I don't care about seeing what is behind the buttons). Is there a way to do this? I have tried setting the toolbar to translucent, but that does not make it completely clear.

Answer

Ievgen picture Ievgen · Apr 16, 2013
[self.toolbar setBackgroundImage:[UIImage new]
              forToolbarPosition:UIToolbarPositionAny
                      barMetrics:UIBarMetricsDefault];

 [self.toolbar setBackgroundColor:[UIColor clearColor]];