簡體   English   中英

iphone主題處於黑暗模式時導航欄樣式更改

[英]navigation bar style change while iphone theme is in dark mode

您好,我正在使用Swift創建應用程序,我剛剛開始創建應用程序並獲取一個View Controllerembed in導航 controller 並用於刪除導航欄邊框我在下面的代碼中使用

self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for:.default)            
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.layoutIfNeeded()

為了處理黑暗主題,我又添加了一行,如下所示

我正在添加亮模式和暗模式的屏幕截圖以獲得更好的解釋

overrideUserInterfaceStyle = .light

但是當iphone處於暗模式導航欄樣式更改為亮時,是否有任何解決方案可以在啟用暗模式時處理導航欄樣式

此黑暗模式屏幕截圖

這是光模式屏幕截圖

請告訴我是否有人對此有任何解決方案

使用UINavigationBarAppearance()自定義 iOS13 中的UINavigationBar (出現暗模式功能):

if #available(iOS 13.0, *) {
   let appearance = UINavigationBarAppearance()
   appearance.backgroundColor = UIColor.colorYouNeed
   self.navigationController?.navigationBar.standardAppearance = appearance
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM