//MyToolbar.h 
头文件
@interface MyToolbar : UIToolbar
 
@end
 
//MyToolbar.m 实现文件
#import 
"MyToolbar.h"
@implementation MyToolbar
- (id)initWithFrame:(CGRect)frame
{
  self = [super 
initWithFrame:frame];
  if (self) {
    //设置自定义的MyToolbar为透明背景
            self.backgroundColor = [UIColor 
clearColor];
  }
  return self;
}
- (void)drawRect:(CGRect)rect
{
  // Drawing code
}
@end
//HomeViewController.h 
头文件(调用mytoolbar的页面)
#import "MyToolbar.h"
@interface HomeViewController ()
@end
//HomeViewController.m 实现文件
@implementation HomeViewController
- (void)viewDidLoad
{
  [super viewDidLoad];
  //创建MyToolbar
  MyToolbar *toolbar = [[MyToolbar 
alloc]initWithFrame:CGRectMake(0, 22, 320, 44)];
  //添加到当前视图中
      [self.view addSubview:toolbar];
}
实现toolbar透明的背景效果,码迷,mamicode.com
原文地址:http://www.cnblogs.com/hw140430/p/3703007.html