iOS15-導(dǎo)航條、UITableView

一、導(dǎo)航條
在iOS 13 UINavigationBar新增了scrollEdgeAppearance屬性,但在iOS 14及更早的版本中此屬性只應(yīng)用在大標(biāo)題導(dǎo)航欄上。在iOS 15中此屬性適用于所有導(dǎo)航欄,導(dǎo)致iOS15系統(tǒng)下之前設(shè)置會有些失效,表現(xiàn)情況有透明的有了顏色或者變成白色。
scrollEdgeAppearance:主要針對視圖中存在滾動視圖頂部根據(jù)導(dǎo)航條底部布局的情況。
我遇到的問題:就是列表跑到導(dǎo)航條下面去了。
我開始用如下代碼

/// 設(shè)置NavigationBar的背景色
- (void)setNavigationBarAppearance
{
    UIImage *navBackgroundImage = [UIImage imageWithColor:self.navigationBarBackgroundColor size:self.navigationController.navigationBar.size];
    if (@available(iOS 15.0, *)) {
        self.navigationBarAppearance = [UINavigationBarAppearance new];
        self.navigationBarAppearance.backgroundColor = self.navigationBarBackgroundColor;
        self.navigationBarAppearance.backgroundImage = navBackgroundImage;
        self.navigationBarAppearance.backgroundEffect = nil;
        self.navigationBarAppearance.shadowColor = self.navigationBarBackgroundColor;
        self.navigationBarAppearance.titleTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:20.0f],
                                       NSForegroundColorAttributeName:QH_title_color(title_000000_000000)};
        self.navigationController.navigationBar.scrollEdgeAppearance = self.navigationBarAppearance;
        self.navigationController.navigationBar.standardAppearance = self.navigationBarAppearance;
    }else{
        //背景色
        [self.navigationController.navigationBar setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault];
        [self.navigationController.navigationBar setBarTintColor:[UIColor clearColor]];
        [self.navigationController.navigationBar setTitleTextAttributes:
         @{NSFontAttributeName:[UIFont systemFontOfSize:20.0f],
                                        NSForegroundColorAttributeName:QH_title_color(title_000000_000000)}];
        [self.navigationController.navigationBar setShadowImage:[UIImage new]];
    }
}

但是沒有效果,經(jīng)過檢查發(fā)現(xiàn)是因為self.navigationController.navigationBar.translucent的問題

二、陰影設(shè)置不生效的問題
給collectionView設(shè)置陰影怎么都不顯示,frame、masksToBounds等都檢查就是不管用,經(jīng)過多方驗證,設(shè)置view等的陰影不成功的原因有以下幾種:
1、設(shè)置viewclipsToBoundsYES,我遇到就是這個collectionViewclipsToBounds竟然默認(rèn)就是YES。
2、viewbackgroundColorclearColor。
3、layer的陰影參數(shù)設(shè)置錯誤。

三、iOS15下UITableView頂部多出了一條空白
查資料發(fā)現(xiàn)iOS15 中 UITableView 新加了一個屬性:sectionHeaderTopPadding,默認(rèn)值為 automaticDimension,就會導(dǎo)致頂部多出一條空白。

    if (@available(iOS 15.0, *)) {
        self.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)容

  • 16宿命:用概率思維提高你的勝算 以前的我是風(fēng)險厭惡者,不喜歡去冒險,但是人生放棄了冒險,也就放棄了無數(shù)的可能。 ...
    yichen大刀閱讀 7,644評論 0 4
  • 公元:2019年11月28日19時42分農(nóng)歷:二零一九年 十一月 初三日 戌時干支:己亥乙亥己巳甲戌當(dāng)月節(jié)氣:立冬...
    石放閱讀 7,408評論 0 2
  • 今天上午陪老媽看病,下午健身房跑步,晚上想想今天還沒有斷舍離,馬上做,衣架和旁邊的的布衣架,一看亂亂,又想想自己是...
    影子3623253閱讀 3,061評論 3 8

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