Search code examples
iphoneobjective-ciosuinavigationbaruitoolbar

How to make UIToolbar have a Clear Background?


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.


Solution

  • [self.toolbar setBackgroundImage:[UIImage new]
                  forToolbarPosition:UIToolbarPositionAny
                          barMetrics:UIBarMetricsDefault];
    
     [self.toolbar setBackgroundColor:[UIColor clearColor]];