簡體   English   中英

如何將“更多”標簽欄的編輯視圖的導航欄設置為黑色?

[英]How to set the “more” tab bar's edit view's navigation bar black?

我正在嘗試設置所有選項卡欄的導航欄UIBarStyleBlack。

我也可以使用以下“更多”標簽欄實現此目的:

tabBarController.moreNavigationController.navigationBar.barStyle = UIBarStyleBlack;

問題是,當您單擊其頂部的“編輯”按鈕以自定義選項卡時,它會顯示一個帶有標准藍色導航欄的新模態控制器,而我無法將其設置為UIBarStyleBlack。

該鏈接具有一個有點駭人聽聞的解決方案,其中涉及偵聽模態視圖何時出現。

用更多的顏色着色樂趣

直到iOS5 +使我們能夠以更清潔的方式進行操作為止。

Swift-自定義標簽欄->更多菜單->編輯視圖(導航欄和內容視圖)。

override func tabBar(_ tabBar: UITabBar, willBeginCustomizing items: [UITabBarItem]) {
    for (index, subView) in view.subviews.enumerated() {
        subView.backgroundColor = UIColor.black
        if index == 1 {
            subView.tintColor = UIColor.green
            for customSubView in subView.subviews {
                if let navBar = customSubView as? UINavigationBar {
                    navBar.isTranslucent = false
                    navBar.barTintColor = UIColor.black
                    navBar.tintColor = .white
                }
            }
        }
    }
}

這對我有用。

Sublcass UITabBarController並覆蓋以下方法:

- (void)tabBar:(UITabBar *)tabBar willEndCustomizingItems:(NSArray<UITabBarItem *> *)items changed:(BOOL)changed {
    self.moreNavigationController.navigationBar.barStyle = UIBarStyleBlack;
}

- (void)tabBar:(UITabBar *)tabBar didBeginCustomizingItems:(NSArray<UITabBarItem *> *)items {
    self.moreNavigationController.navigationBar.barStyle = UIBarStyleDefault;
}

暫無
暫無

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

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