iOS 15適配

1、導(dǎo)航欄和底部欄的適配

在iOS 15中,UINavigationBar默認為透明。在滑動時會有模糊效果。UINavigationBar、UIToolbar 和 UITabBar 將在你的VC關(guān)聯(lián)滾動視圖位于適當(dāng)?shù)倪吘墪r使用 scrollEdgeAppearance。如果不想要透明設(shè)置如下:

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 增加一個默認高度,當(dāng)我們使用 UITableViewStylePlain 初始化UITableView 的時候,系統(tǒng)默認給 section header 增高了22像素。

解決辦法:

        if #available(iOS 15.0, *) {
            tableView.sectionHeaderTopPadding = 0
        }
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 前言 iOS 15在2021 WWDC會后發(fā)布,就勇猛的把水果全家桶都升級了最新系統(tǒng)。兩個iOS 15 beta版...
    TripleEyeAline閱讀 7,645評論 2 11
  • 本文作為自己準備適配iOS15所用,在開始適配之前,先去學(xué)習(xí)各位同學(xué)的文章,記錄在此備用。 1、導(dǎo)航欄UINavi...
    iOS_zy閱讀 14,750評論 5 61
  • 1、UINavigationBar 在iOS 15中,UINavigationBar默認為透明。在滑動時會有模糊效...
    nick5683閱讀 6,527評論 0 19
  • 導(dǎo)航欄 從 iOS 15 開始,UINavigationBar、UIToolbar 和 UITabBar 在控制器...
    牧兮閱讀 27,795評論 0 23
  • 16宿命:用概率思維提高你的勝算 以前的我是風(fēng)險厭惡者,不喜歡去冒險,但是人生放棄了冒險,也就放棄了無數(shù)的可能。 ...
    yichen大刀閱讀 8,211評論 0 4

友情鏈接更多精彩內(nèi)容