iOS13適配相關

Dark Mode 暗黑模式簡介

官方文檔:

In iOS 13.0 and later, people can choose to adopt a dark system-wide appearance called Dark Mode. In Dark Mode, the system uses a darker color palette for all screens, views, menus, and controls, and it uses more vibrancy to make foreground content stand out against the darker backgrounds. Dark Mode supports all accessibility features.
在iOS 13.0或更高版本中,人們可以選擇採用一種名爲dark Mode的全系統暗模式。在暗模式下,系統對所有屏幕、視圖、菜單和控件使用較暗的調色板,並使用更多的活力使前景內容在較暗的背景中脫穎而出。暗模式支持所有可訪問性特性。

關閉APP的暗黑模式

iOS13更新後可能需要對UI進行相應的適配,那麼開發者很關心的一個問題,如何在APP UI中關閉暗黑模式呢。
很簡單,在Info.plist文件中添加Key:User Interface Style,值類型設置爲String,值爲Light,重新運行項目就OK了。

在這裏插入圖片描述

暗黑模式下導航欄標題顏色修改

切換到暗黑模式(Dark Mode)下導航欄標題會變成白色,可以用如下代碼修改顏色。

[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor redColor],NSFontAttributeName:[UIFont systemFontOfSize:17]}];

在這裏插入圖片描述

控件的背景顏色

官方文檔中描述:
When you use the system-defined materials, your elements look great in every context, because these effects automatically adapt to the system’s light and dark modes.
當您使用系統定義的材料時,您的元素在任何上下文中看起來都很棒,因爲這些效果會自動適應系統的亮模式和暗模式。

在暗黑模式下,開發中必須指定控件的顏色,如單元格的背景色,字體的顏色等,如果使用系統默認顏色,切換到暗黑模式下背景顏色會變成黑色或字體會變成白色,影響展示的可能性很大。

在這裏插入圖片描述

隱藏導航欄底部邊框

Human Interface Guidelines 中提到:
Consider hiding the border of a large-title navigation bar. In iOS 13 and later, you can hide the bottom border of a navigation bar by removing the bar’s shadow (the border automatically reappears when people scroll the content area).
我們可以利用到的就是:
在iOS 13或更高版本中,你可以通過移除導航欄的陰影來隱藏導航欄的底部邊框(當用戶滾動內容區域時,邊框會自動重新出現)。

 [self.navigationController.navigationBar setShadowImage: [[UIImage alloc] init]];

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章