原文链接:http://blog.csdn.net/wanglixin1999/article/details/46947655
这个问题一直比较苦恼,网上很多方法实验下来都不是很好,今天终于解决了。
直接上代码:
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"]];
//如果需要不显示分割线,只需要将下面一句话
[self.tabBar setClipsToBounds:YES];