通過設(shè)置backgroundimage
- (UIImage *)createImageWithColor:(UIColor *)color {
? ? CGRectrect=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();
? ? returntheImage;
}
在viewdidload中加上
//Tabbar的上橫線
[[UITabBar appearance] setShadowImage:[selfcreateImageWithColor:[UIColor orangeColor]]];
//背景圖片
? ? ? ? [[UITabBar appearance] setBackgroundImage:[selfcreateImageWithColor:kColorWith(0,0,0,.65)]];
? ? ? ? self.tabBar.backgroundColor = [UIColor clearColor];
? ? //設(shè)置為半透明
? ? ? ? self.tabBarController.tabBar.translucent = YES;