簡體   English   中英

刪除使用故事板創建的導航欄中的半透明欄

[英]remove translucent bar in navigation bar created with storyboard

我從故事板創建了一個navigationController,現在我正在嘗試刪除它的半透明選項

我把它放在我的appdelegate.m上

[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:52.0/255 green:152.0/255 blue:219.0/255 alpha:1]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];

[[UINavigationBar appearance] setTranslucent:NO];

但這會導致我的應用程序崩潰,但是我不確定這是否是正確的方法。

我發現了類似的問題,但沒有解決我的問題: 導航控制器透明欄樣式無法正常工作

但我不知道該怎么做,因為我沒有變量navController,因為我從故事板創建了我的navigationController。 如何以編程方式調用故事板導航控制器並執行類似的操作?

謝謝

如果您使用故事板設計視圖,則可以使用XCode解決問題。 選擇NavigationBar小部件並取消選中“Translucent”。

XCode 5

將此添加到導航堆棧上顯示的第一個視圖控制器上的viewDidLoad

self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;

如果您不使用故事板,而是使用IB,請將MainWindow.xib中的導航欄樣式設置為NOT半透明並將其設置為顏色而不是清晰顏色。

暫無
暫無

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

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