iOS 13 tabbar背景透明化和去掉分割线

5,758 阅读1分钟
  • configureWithTransparentBackground 需要放在设置好颜色的后面
  • [appearance configureWithTransparentBackground]; // 是重点代码
if (@available(iOS 13, *)) {
        UITabBarAppearance *appearance = [self.tabBar.standardAppearance copy];
        appearance.backgroundImage = [UIImage imageWithColor:[UIColor clearColor]];
        appearance.shadowImage = [UIImage imageWithColor:[UIColor clearColor]];
         // 官方文档写的是 重置背景和阴影为透明
        [appearance configureWithTransparentBackground];
        self.tabBar.standardAppearance = appearance;
} else {
            self.tabBar.backgroundImage = [UIImage new];
            self.tabBar.shadowImage = [UIImage new];
}