![](/img/trans.png)
[英]iPhone - How to set custom color in the “More” item's navigation bar?
[英]How to set the “more” tab bar's edit view's navigation bar black?
我正在嘗試設置所有選項卡欄的導航欄UIBarStyleBlack。
我也可以使用以下“更多”標簽欄實現此目的:
tabBarController.moreNavigationController.navigationBar.barStyle = UIBarStyleBlack;
問題是,當您單擊其頂部的“編輯”按鈕以自定義選項卡時,它會顯示一個帶有標准藍色導航欄的新模態控制器,而我無法將其設置為UIBarStyleBlack。
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.