我已將我的 Xcode 更新為 13,后來我的舊專案導航和標簽欄顏色中的文字更改為透明。
我的代碼是
[[UINavigationBar appearance] setBarTintColor:[UIColor AppThemeColour]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTranslucent:NO];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
我試圖添加背景顏色,但導航欄的標題和影像沒有出現。
self.navigationController.navigationBar.backgroundColor = [UIColor bOneAppThemeColor];
[[UINavigationBar appearance] setBarTintColor:[UIColor AppThemeColour]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTranslucent:NO];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
我已經研究了下面的鏈接,但我無法在目標 C 中實作它
https://developer.apple.com/forums/thread/682420
uj5u.com熱心網友回復:
您所做的幾乎所有事情都是錯誤的(并且已經錯誤了好幾年)。您需要使用 UINavigationBarAppearance(和 UITabBarAppearance)并將它們應用到欄standardAppearance和它的scrollEdgeAppearance. 設定外觀的背景顏色,而不是它的色調。并且translucent永遠不要觸摸該財產。
在這個簡單的例子中,我們讓所有導航欄都采用您的主題顏色。修改以滿足您的需求和愿望:
if (@available(iOS 13.0, *)) {
UINavigationBarAppearance* appear = [UINavigationBarAppearance new];
appear.backgroundColor = [UIColor AppThemeColor];
id proxy = [UINavigationBar appearance];
[proxy setStandardAppearance: appear];
[proxy setScrollEdgeAppearance: appear];
} else {
// Fallback on earlier versions
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/329183.html
