iOS 15适配

1、导航栏和底部栏的适配

在iOS 15中,UINavigationBar默认为透明。在滑动时会有模糊效果。UINavigationBar、UIToolbar 和 UITabBar 将在你的VC关联滚动视图位于适当的边缘时使用 scrollEdgeAppearance。如果不想要透明设置如下:

navigationBar

        if #available(iOS 15.0, *) {
            let bar = UINavigationBarAppearance()
            bar.backgroundColor = UIColor.rgbColorFromHex(rgb: 0x0855FF)
            bar.titleTextAttributes = [NSAttributedString.Key.foregroundColor :UIColor.white]
//            bar.backgroundEffect = nil
            self.navigationBar.scrollEdgeAppearance = bar // 可滑动界面配置
            self.navigationBar.standardAppearance = bar // 普通页面配置
            self.navigationBar.isTranslucent = false
        }

tabBar

            if #available(iOS 15.0, *) {
                let bar = UITabBarAppearance()
                bar.stackedLayoutAppearance.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor :UIColor.rgbColorFromHex(rgb: 0x1E1E1E)]
                bar.stackedLayoutAppearance.selected.titleTextAttributes = [NSAttributedString.Key.foregroundColor :UIColor.rgbColorFromHex(rgb: 0x1E1E1E)]
                bar.backgroundColor = .white
                self.tabBar.scrollEdgeAppearance = bar
                self.tabBar.standardAppearance = bar
            }

2、iOS 15 UITableView sectionHeader下移22像素

iOS 15中 UITableView 新增了一个属性:sectionHeaderTopPadding。此属性会给每一个 section header 增加一个默认高度,当我们使用 UITableViewStylePlain 初始化UITableView 的时候,系统默认给 section header 增高了22像素。

解决办法:

        if #available(iOS 15.0, *) {
            tableView.sectionHeaderTopPadding = 0
        }
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 前言 iOS 15在2021 WWDC会后发布,就勇猛的把水果全家桶都升级了最新系统。两个iOS 15 beta版...
    TripleEyeAline阅读 7,511评论 2 11
  • 本文作为自己准备适配iOS15所用,在开始适配之前,先去学习各位同学的文章,记录在此备用。 1、导航栏UINavi...
    iOS_zy阅读 14,499评论 5 61
  • 1、UINavigationBar 在iOS 15中,UINavigationBar默认为透明。在滑动时会有模糊效...
    nick5683阅读 6,283评论 0 19
  • 导航栏 从 iOS 15 开始,UINavigationBar、UIToolbar 和 UITabBar 在控制器...
    牧兮阅读 27,723评论 0 23
  • 16宿命:用概率思维提高你的胜算 以前的我是风险厌恶者,不喜欢去冒险,但是人生放弃了冒险,也就放弃了无数的可能。 ...
    yichen大刀阅读 6,098评论 0 4