这个问题一直比较苦恼,网上很多方法实验下来都不是很好,今天终于解决了。
直接上代码:
CGRect rect = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]);
CGContextFillRect(context, rect);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[self.tabBar setBackgroundImage:img];
[self.tabBar setShadowImage:img];
[self.tabBar setBackgroundImage:[UIImage imageNamed:@"tabbarbg3.jpg"]];