美文网首页
ios15相关适配

ios15相关适配

作者: hypercode | 来源:发表于2021-10-08 16:59 被阅读0次

一、适配导航条的两种方式

    if (@available(iOS 15.0, *)) {
        UINavigationBarAppearance *appearance = [UINavigationBarAppearance new];
        [appearance configureWithOpaqueBackground];
        appearance.backgroundColor = [UIColor cyanColor];
//        UIBarButtonItemStateAppearance *normal = appearance.buttonAppearance.normal;
//        UIBarButtonItemStateAppearance *highlighted = appearance.buttonAppearance.highlighted;
//        highlighted.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor],
//                                            NSFontAttributeName:[UIFont systemFontOfSize:20]};
//        normal.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor],
//                                       NSFontAttributeName:[UIFont systemFontOfSize:20]};
        appearance.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor],
                                           NSFontAttributeName:[UIFont systemFontOfSize:20]};
        self.navigationBar.standardAppearance = appearance;
        self.navigationBar.scrollEdgeAppearance=self.navigationBar.standardAppearance;
    }else{
        self.navigationBar.barTintColor =  [UIColor redColor];
        self.navigationBar.translucent = YES;
        self.navigationBar.tintColor = [UIColor whiteColor];
        [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],
                                                     NSFontAttributeName:[UIFont systemFontOfSize:20]}];
    }
    [self.view insertSubview:self.barView belowSubview:self.navigationBar];
    [self.barView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(0);
        make.left.offset(0);
        make.right.offset(0);
        CGFloat height = [AppManager vcTopHight];
        make.height.mas_equalTo(height);
        ;
    }];

    [self.navigationBar setBackgroundImage: [UIImage new] forBarMetrics:UIBarMetricsDefault];
    [self.navigationBar setShadowImage:[UIImage new]];
    [self.navigationBar setTintColor:[UIColor clearColor]];

二、一些工程不得不变成 New Build System引发编译不过的解决方法:
Build Phases里某些地方的 Run script勾选上 For install builds only即可。

三、tabBar

UITabBarAppearance *appearance = [[UITabBarAppearance alloc] init];
//tabBaritem title选中状态颜色
appearance.stackedLayoutAppearance.selected.titleTextAttributes = @{
    NSForegroundColorAttributeName:[UIColor blueColor],
};
//tabBaritem title未选中状态颜色
appearance.stackedLayoutAppearance.normal.titleTextAttributes = @{
    NSForegroundColorAttributeName:[UIColor blueColor],
};
//tabBar背景颜色
appearance.backgroundColor = [UIColor blackColor];
self.tabBarItem.scrollEdgeAppearance = appearance;
self.tabBarItem.standardAppearance = appearance;

其中 standardAppearance和scrollEdgeAppearance等的区别 
standardAppearance --- 常规状态
scrollEdgeAppearance --- 小屏幕手机横屏时的状态
scrollEdgeAppearance --- 呗scrollview向下拉的状态

四,未完待续

相关文章

  • iOS15适配相关

    1、tabbar相关 UITabBarAppearance *appearance = [[UITabBarApp...

  • iOS 15 适配

    一年一系统,一年一适配。今天我们来讲一下iOS15适配的相关地方。导航栏适配iOS 15中,导航栏的问题比较明显,...

  • html2canvas在ios15系统截图空白并刷新

    随着ios15系统的出现,项目适配ios15系统兼容性。 发现html2canvas在iOS15系统中截图空白并在...

  • iOS15 适配更新总结

    本文主要分享一下 iOS15 上适配方案,仅做开发记录使用,开发过程中通过使用陆续增加。 iOS15 的适配,很重...

  • iOS开发技巧之:iOS15 适配更新总结

    本文主要分享一下 iOS15 上适配方案,仅做开发记录使用,开发过程中通过使用陆续增加。 iOS15 的适配,很重...

  • iOS15适配

    iOS15适配主要是以下几点:UINavigationController、UITabBarController、...

  • iOS15适配

    对于iOS15适配汇总以及遇到的问题 注意:以下适配内容,必须适配的会以"必须"标出 UITableView Se...

  • iOS 15 适配笔记

    前言 环境 在 升级xcode 13.0 之后,正式开始支持 iOS15,就需要做适配 iOS15了,在 xcod...

  • ios15相关适配

    一、适配导航条的两种方式 二、一些工程不得不变成 New Build System引发编译不过的解决方法:Buil...

  • 日期篇

    1. NSDateFormatter 1.1 系统适配 iOS15以下dateFormat = @"HH:mm" ...

网友评论

      本文标题:ios15相关适配

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