I wrote the following code to make my toolbar transparent.
[mtoolbar setBackgroundColor:[UIColor clearColor]];
How do I make UIToolbar
The following works in iOS 5 (and iOS 6 beta 4, although a slight top shadow is still visible there).
Please note: Making a UIToolbar or UINavigationBar transparent is rarely a good idea, and modifying Apple's UIKit elements in such a way is bound to break sooner or later.
TransparentToolbar.h
#import
@interface TransparentToolbar : UIToolbar
@end
TransparentToolbar.m
#import "TransparentToolbar.h"
@implementation TransparentToolbar
-(void)insertSubview:(UIView *)view atIndex:(NSInteger)index
{
// This method is called with a view of class "UINavigationBarBackground" or "_UIToolbarBackground", respectively. It would be possible to check for this with NSStringFromClass([view class]) to be completely sure that we're skipping the right view.
if (index != 0)
{
[super insertSubview:view atIndex:index];
}
else
{
// insert your custom background view, if you want to
}
}
@end
EDIT: In iOS 5+, it's also possible to simply set the backgroundImage (which could be transparent). This is certainly the "cleaner" solution, but is less flexible than a custom UIView
.
[someToolbar setBackgroundImage:[UIImage imageNamed:@"clear"] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];