簡體   English   中英

嘗試更改導航欄背景顏色,但失敗

[英]try to change navigationbar background color but failed

我使用下面的代碼更改了導航欄的背景顏色

- (void)viewDidLoad
{

    [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithHexString:@"6cd3c5"]];

    [super viewDidLoad];

}

酒吧背景顏色不會立即改變,我必須pushViewController:someViewController

然后返回,顏色可能會改變。

歡迎您發表評論

嘗試這個:

[self.navigationController.navigationBar setBarTintColor:[UIColor colorWithHexString:@"6cd3c5"]];
[self.navigationController.navigationBar setTranslucent:NO];

閱讀此內容以獲得更多說明。

appearance用於將來的外觀。 如果要顯示外觀,請在加載視圖之前使用。

否則使用

    [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithHexString:@"6cd3c5"]];

暫無
暫無

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

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