簡體   English   中英

修改從UITabBarController的“更多”選項卡顯示的選項卡的導航欄上的“更多”按鈕

[英]Modify the More button on the Navigation bar of a tab displayed from a UITabBarController's More tab

我有一個帶有UITabBarController的應用程序,該應用程序具有五個以上的選項卡。

在此處輸入圖片說明

當我按“ 更多”選項卡時,我轉到moreNavigationController ,它是一個UINavigationController

在此處輸入圖片說明

正如你所看到的,我已經找到了如何風格的標題色調表色 ,和更多屏幕上的編輯按鈕,以及從按下Edit按鈕配置屏幕。

當我在表格中選擇一個項目時,我還無法弄清如何設置后退按鈕的樣式,該標題為“ 更多 ”。

在此處輸入圖片說明

每個選項卡都有其自己的類,例如GRWTabSettingsViewController該類繼承自GRWViewController ,后者為所有選項卡提供通用功能,然后繼承自UIViewController

在“ 設置”屏幕(或任何其他標簽)上時,我正在嘗試編輯“ 更多后退”按鈕。

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    [(UIBarButtonItem *)[(UINavigationItem *)[(UINavigationBar *)[(UINavigationController *)[self navigationController] navigationBar] topItem] leftBarButtonItem] setTintColor:[UIColor darkGrayColor]]; 
    [self.navigationController.navigationBar.topItem.leftBarButtonItem setTintColor:[UIColor darkGrayColor]];
}

但是,此NavigationController顯然是父級,因為這些更改將應用​​於“ 更多”屏幕,而不是“ 設置”屏幕。

我有什么誤解,如何修改正在查看的屏幕的導航欄上顯示的按鈕?

===解決方案===

在此處輸入圖片說明

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    // use backBarButtonItem not leftBarButtonItem
    //[(UIBarButtonItem *)[(UINavigationItem *)[(UINavigationBar *)[(UINavigationController *)[self navigationController] navigationBar] topItem] leftBarButtonItem] setTintColor:[UIColor darkGrayColor]];
    //[self.navigationController.navigationBar.topItem.leftBarButtonItem setTintColor:[UIColor darkGrayColor]];

    UIBarButtonItem *backButton = [[UIBarButtonItem alloc]
                                   initWithTitle:self.navigationController.navigationBar.topItem.title
                                   style:UIBarButtonItemStylePlain
                                   target:nil
                                   action:nil];
    [backButton setTintColor:[UIColor darkGrayColor]];

    self.navigationController.navigationBar.topItem.backBarButtonItem = backButton;
    // these do not work
    //[self.navigationController.navigationBar.topItem.backBarButtonItem setTintColor:[UIColor darkGrayColor]];
    //[backButton setTintColor:[UIColor darkGrayColor]];
}

確實花了我一段時間才能弄清楚我無法通過self格式化按鈕,也無法在分配給self之后格式化按鈕。

你應該定制backBarButtonItem以前的導航項目的,不是的topItem

暫無
暫無

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

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