Ios7 透明UIToolBar与非透明UIBarButtonim

Ios7 透明UIToolBar与非透明UIBarButtonim,ios7,uibarbuttonitem,uitoolbar,Ios7,Uibarbuttonitem,Uitoolbar,我有一个透明的UIToolbar,通过设置半透明为true并更改背景alpha。如何使工具栏按钮不透明?我尝试添加如下非透明图像: CGRect rect = CGRectMake(0, 0, ([AppDelegate isInIPad])?768:320, 20); UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColo

我有一个透明的UIToolbar,通过设置半透明为true并更改背景alpha。如何使工具栏按钮不透明?我尝试添加如下非透明图像:

CGRect rect = CGRectMake(0, 0, ([AppDelegate isInIPad])?768:320, 20);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [[UIColor redColor] CGColor]);
CGContextFillRect(context, rect);

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

[self.filterButton setBackgroundImage:image forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
试试这个:

[yourToolbar setBackgroundImage:[UIImage new] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];    
[yourToolbar setBackgroundColor:[UIColor clearColor]];    
[yourToolbar setShadowImage:[UIImage new] forToolbarPosition:UIToolbarPositionAny];