tabbar navigation黑线的处理(隐藏及颜色修改)

    xiaoxiao2024-12-24  18

    //   去除tabbar顶部的线

          [self.tabBarsetBackgroundImage:[[UIImagealloc]init]];

    //      去除navigationbar底部的黑线

            [self.navigationBarsetShadowImage:[UIImagenew]];

    //    修改tabbar的颜色

        UIView *backView = [[UIViewalloc] initWithFrame:CGRectMake(0,0, [UIScreenmainScreen].bounds.size.width,49)];

        backView.backgroundColor =TabColor;

    //    修改tabbar黑线的颜色

        UIView *line = [[UIViewalloc]initWithFrame:CGRectMake(0,0,ScreenWidth,LineHeight)];

        line.backgroundColor =LineColor;

        [self.tabBarinsertSubview:line atIndex:0];

        [self.tabBarinsertSubview:backView atIndex:0];

        self.tabBar.opaque =YES;

    //    设置navbar的颜色

        [self.navigationBarsetBackgroundImage:[Helper imageWithTheColor:NavColor]forBarPosition:UIBarPositionTopbarMetrics:UIBarMetricsDefault];

    //    设置navbar下面线条颜色

        [self.navigationBarsetShadowImage:[Helper imageWithTheColor:[UIColor colorFromHexRGB:@"e7e7e7"]]];

    #import "Helper.h"

    @implementation Helper

    //生成全色的图片

    + (UIImage *)imageWithTheColor:(UIColor *)color {

        CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);

        //打开图片上下文

        UIGraphicsBeginImageContext(rect.size);

        //获取当前图片上下文

        CGContextRef context = UIGraphicsGetCurrentContext();

        //设置颜色

        CGContextSetFillColorWithColor(context, [color CGColor]);

        //填充颜色

        CGContextFillRect(context, rect);

        //生成图片

        UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

        //结束绘画

        UIGraphicsEndImageContext();

        

        return image;

    }

    @end

    转载请注明原文地址: https://ju.6miu.com/read-1294939.html
    最新回复(0)