iOS 13 怎么去掉UITabbar顶部黑线

代码如下:

  //去掉tabbar黑线,其中self是一个UITabbarController,imageWithColor是由颜色生产图片的方法

    if (@available(iOS 13.0, *)) {

        UITabBarAppearance *apperance= self.tabBar.standardAppearance;

        apperance.backgroundImage=[self imageWithColor:[UIColor clearColor]];

        apperance.shadowImage = [self imageWithColor:[UIColor clearColor]];

        self.tabBar.standardAppearance = apperance;

    } else {

        self.tabBar.backgroundImage = [self imageWithColor:[UIColor clearColor]];

        self.tabBar.shadowImage = [self imageWithColor:[UIColor clearColor]];

    };

//自定义颜色生产UIImage,对象

- (UIImage *)imageWithColor:(UIColor *)color {

    CGRect rect = CGRectMake(0, 0, 1, 1);

    UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);

    [color setFill];

    UIRectFill(rect);

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return image;

}

 

你可能感兴趣的:(iOS码农)