//去掉默认黑线
self.tabBar.backgroundColor=[UIColor whiteColor];
[[UITabBarappearance]setShadowImage:[UIImagenew]];
[[UITabBarappearance]setBackgroundImage:[[UIImagealloc]init]];
//设置阴影
[selfdropShadowWithOffset:CGSizeMake(0, -0.5)
radius:1
color:[UIColorlightGrayColor]
opacity:0.3];
- (void)dropShadowWithOffset:(CGSize)offset
radius:(CGFloat)radius
color:(UIColor *)color
opacity:(CGFloat)opacity {
// Creating shadow path for better performance
CGMutablePathRef path =CGPathCreateMutable();
CGPathAddRect(path,NULL,self.tabbarView.bounds);
self.tabbarView.layer.shadowPath = path;
CGPathCloseSubpath(path);
CGPathRelease(path);
self.tabbarView.layer.shadowColor = color.CGColor;
//阴影偏移度向右0 向上0.5
self.tabbarView.layer.shadowOffset = offset;
//阴影半径
self.tabbarView.layer.shadowRadius = radius;
//阴影透明度
self.tabbarView.layer.shadowOpacity = opacity;
// Default clipsToBounds is YES, will clip off the shadow, so we disable it.
self.tabbarView.clipsToBounds = NO;
}