[self.tabBar setSelectionIndicatorImage:透明图片];
setSelectionIndicatorImage函数是设置tabbarItem选中时的背景图片
没有透明背景图片的话可以自己生成一张透明的图片。下面的函数就是根据UIColor生成UIImage的方法
- (UIImage *) createImageWithColor: (UIColor *) color
{
CGRect rect=CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
所以上面的问题可以写成:
[self.tabBar setSelectionIndicatorImage:[self createImageWithColor:[UIColor clearColor]]];