美文网首页日常收录
iOS 15 导航栏适配、去除导航栏横线和iOS 15适配Tab

iOS 15 导航栏适配、去除导航栏横线和iOS 15适配Tab

作者: KevinCX | 来源:发表于2022-05-12 14:45 被阅读0次

    1、iOS15 适配导航栏

    之前的导航栏设置方法失效了,具体原因可以参考 详情参考官网,现在需要通过 UINavigationBarAppearance 方式进行设置:
    、、、
    if (@available(iOS 15.0, *) ) {
    UINavigationBarAppearance * appearance = [[UINavigationBarAppearance alloc] init];
    [appearance configureWithTransparentBackground];// 去除横线
    appearance.backgroundColor = APP_BLACK_2C2E44_COLOR;// 导航栏背景色
    appearance.titleTextAttributes = @{NSForegroundColorAttributeName:UIColor.whiteColor};// 导航栏标题颜色
    [UINavigationBar appearance].standardAppearance = appearance;
    [UINavigationBar appearance].scrollEdgeAppearance = appearance;
    [[UINavigationBar appearance] setScrollEdgeAppearance:appearance];
    [[UINavigationBar appearance] setStandardAppearance:appearance];
    }
    、、、

    2、iOS15 适配Tabbar

    现在需要通过 UITabBarAppearance 方式进行设置:

    if (@available(iOS 15.0, *)) {
    UITabBarAppearance * appearance = [[UITabBarAppearance alloc] init];
    appearance.backgroundColor = UIColor.whiteColor;
    appearance.stackedLayoutAppearance.normal.titleTextAttributes = @{NSForegroundColorAttributeName:APP_GRAY_333333_COLOR};// tabbar未选中字体颜色
    appearance.stackedLayoutAppearance.selected.titleTextAttributes = @{NSForegroundColorAttributeName:APP_GRAY_333333_COLOR};// tabbar选中字体颜色
    appearance.stackedLayoutAppearance.normal.iconColor = APP_GRAY_333333_COLOR;// tabbar未选中图片颜色
    [UITabBar appearance].scrollEdgeAppearance = appearance;
    [UITabBar appearance].standardAppearance = appearance;
    }
    、、、

    如有不对,请帮忙指正

    相关文章

      网友评论

        本文标题:iOS 15 导航栏适配、去除导航栏横线和iOS 15适配Tab

        本文链接:https://www.haomeiwen.com/subject/hvnsurtx.html