修改导航栏(公司框架的导航栏,非原生)的背景色

原理:找到导航栏的顶部背景图,盖上一个view


for (UIView *barBackground in _mainNav.navigationBar.subviews) {
        if ([barBackbround isKindOfClass:NSClassFromString(@"_UIBarBackground")]) {
            
            UIView *darkBlueView = [[UIView alloc] initWithFrame:CGRectMake(0, -64, [UIScreen mainScreen].bounds.size.width, 64)];
            darkBlueView.backgroundColor = [TKIMColorHelper stringToColor:@"#4359AA"];
            
            UIView *tintBlueImageView = barBackground.subviews.firstObject;
            [tintBlueImageView addSubview:darkBlueView];
        }
    }

你可能感兴趣的:(修改导航栏(公司框架的导航栏,非原生)的背景色)