兼容iOS15 导航栏 字体 去掉导航栏下横线

1、设置导航栏字体 去掉导航栏下横线

// 设置导航栏的标题颜色,字体
    NSDictionary* textAttrs = @{NSForegroundColorAttributeName:
                                    [UIColor whiteColor],
                                NSFontAttributeName:
                                    [UIFont fontWithName:@"Helvetica-Bold"size:17.0],
                                };

    if (@available(iOS 13.0, *)) {
        UINavigationBarAppearance * barAp = [UINavigationBarAppearance new];
        barAp.backgroundColor = [UIColor clearColor];
        barAp.backgroundEffect = nil;
        barAp.backgroundImage = [UIImage new];
        barAp.titleTextAttributes = titleAtrr;//设置字体颜色
        barAp.shadowImage = [UIImage sd_imageWithColor:UIColor.whiteColor];// 去掉导航栏阴影线的关键。
//        bar.shadowImage = [UIImage new]; //未生效
//        barAp.shadowColor = [UIColor whiteColor];//直接设置 shadowColor 颜色也可以 去掉导航栏阴影线。
        self.navigationController.navigationBar.scrollEdgeAppearance = barAp;
        self.navigationController.navigationBar.standardAppearance = barAp;
    } else {
        [self.navigationController.navigationBar setTitleTextAttributes:textAttrs];
    }

2、设置TabBar 字体

  • sd
  • sda
  • a
{{o.name}}
{{m.name}}

猜你喜欢

转载自my.oschina.net/u/5142578/blog/5462739