一位老客戶要求我對他的應用程式進行一些小的更新。為 iOS 15 及更高版本編譯時,底部工具列現在為黑色(在短暫閃爍原始預期顏色后)。我在導航欄上遇到了同樣的問題,并用下面的代碼解決了這個問題,但底部的工具列仍然有問題。(這個應用程式是很久以前撰寫的,所以在 Objective C 中也是如此,但我會感謝 Objective C 或 Swift 中的答案)。
UINavigationBarAppearance *appearance = [UINavigationBarAppearance new];
[appearance configureWithOpaqueBackground];
appearance.backgroundColor = [CommonColors colorWithHexString:@"174594"];
appearance.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};
self.navigationController.navigationBar.standardAppearance = appearance;
self.navigationController.navigationBar.scrollEdgeAppearance = self.navigationController.navigationBar.standardAppearance;
我想使用 UIToolbarAppearance 做類似的事情,但無法使其作業。這是我嘗試過的:
UIToolbarAppearance *toolbarAppearance = [UIToolbarAppearance new];
[toolbarAppearance configureWithOpaqueBackground];
toolbarAppearance.backgroundColor = [CommonColors colorWithHexString:@"174594"];
toolbarAppearance.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};
self.navigationController.toolbar.standardAppearance = toolbarAppearance;
謝謝你的幫助。
uj5u.com熱心網友回復:
根據上面馬特的評論,我為工具列設定了所有四種外觀:
UIToolbarAppearance *toolbarAppearance = [UIToolbarAppearance new];
[toolbarAppearance configureWithOpaqueBackground];
toolbarAppearance.backgroundColor = [CommonColors colorWithHexString:@"F7F7F7"];
self.navigationController.toolbar.standardAppearance = toolbarAppearance;
self.navigationController.toolbar.scrollEdgeAppearance = toolbarAppearance;
self.navigationController.toolbar.compactScrollEdgeAppearance = toolbarAppearance;
self.navigationController.toolbar.compactAppearance = toolbarAppearance;
(CommonColors 是我自己的用于轉換顏色的自定義類,但可以使用任何獲取 UIColor 的標準方法)。
uj5u.com熱心網友回復:
不確定這是否有效,但在我的情況下,設定工具列顏色已經解決了這個問題:
迅速:
UIToolbar.appearance().barTintColor = "your_color"
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/516261.html
上一篇:PactMaven-Springboot研討會步驟1失敗并出現IllegalStateException:FailedtogetnestedarchiveforentryBOOT-INF/lib/lo
下一篇:“[AppDelegate視窗]:無法識別的選擇器已發送到實體”自0.69.6到0.70.2版本以來的AppClip和任何其他目標的錯誤
