网上找了好多都不起作用,下面这个亲测有效!
CGRect rect = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]);
CGContextFillRect(context, rect);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
if (@available(iOS 13.0, *)) {
UITabBarAppearance *tabBarAppearance = [self.tabBar.standardAppearance copy];
[tabBarAppearance setBackgroundImage:img];
[tabBarAppearance setShadowColor:[UIColor clearColor]];
[self.tabBar setStandardAppearance:tabBarAppearance];
} else {
[self.tabBar setBackgroundImage:img];
[self.tabBar setShadowImage:img];
}