2016-09-19 109 views
1

將Xcode更新爲Xcode 8後,我正面臨着這個奇怪的問題。我有一個標籤欄,並在其中3個選項卡時TAB1選擇標籤欄和導航是這樣的:更新到Xcode 8後,tabBar&導航欄變黑了

標籤欄的背景色爲白色,但其呈現出深色而不是

enter image description here

當我選擇任何其他選項卡中的問題得到解決

下面的圖片中我選擇TAB2

enter image description here

我不知道爲什麼會發生,但在tab1的ViewController我有一個tableView和tab2我有一個ViewController

有人知道爲什麼會發生這種情況?

調試層次:

當任何其他選項卡中選擇 enter image description here

我不知道爲什麼,但的TabBar的UIVisualEffectBackdropView的背景色爲黑色TAB1當TAB1選擇 enter image description here


其透明 其他標籤

+0

這看起來像你有另一個視圖或掩碼的頂部。不僅背景不同,標籤圖像顏色也顯得不同。或者檢查一些alpha-s。如果你已經設置了一些alpha,那麼之前的iOS SDK可能還沒有明白。 – pedrouan

+0

請參閱下面的答案。希望這已經爲你解決了。 –

回答

1

轉出我的工具欄添加陰影造成的問題:

下面的代碼是給我正確的陰影Xcode7(SWIFT 2),但更新到Xcode中8後(SWIFT 3)它改變了我的其他條顏色(標籤欄+導航欄):

toolbar.layer.masksToBounds = false 
toolbar.layer.shadowOffset = CGSize(width: -1, height: 1) 
toolbar.layer.shadowRadius = 1 
toolbar.layer.shadowOpacity = 0.5 
2

您可以在本地解決此問題(例如,如果你有一個CustomTabBarController)和全局。我在這裏提供兩種解決方案,只爲你:

1.本地:

class YourCustomTabBarVC: UITabBarController { 

    //MARK:- Initializers 
    required init?(coder aDecoder:NSCoder) { 
     super.init(coder: aDecoder) 
     __customInit() 
    } 

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { 
     super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) 
     __customInit() 
    } 

    fileprivate func __customInit() { 
     addObservers() 

     //Customize TabBar appearance: 
     tabBar.backgroundColor = UIColor.white 
    } 
    } 

2.全球:在您的AppDelegate.swift:

func application(_ application: UIApplication, 
       didFinishLaunchingWithOptions 
    launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
    /* Your other code*/ 
    UITabBar.appearance().backgroundColor = UIColor.white // {UR_DESIRED_COLOR} 

} 

我會建議你使用全局方法。添加那一行,瞧!你將會爭先恐後地在這裏寫下個人感謝信息!

4

對於別人的痛苦這個問題的原因不盡相同,以OP:

當我增加了行edgesForExtendedLayout = []到我UIViewController的loadView()方法stop my view going under the navigation bar發生了我這個確切的問題。因此,刪除該行,並使用navigationController?.navigationBar.isTranslucent = false實現相同的目標,爲我解決了這個問題(雖然John Doe的解決方案也可能是可行的)。我想當你的工具欄下沒有任何視圖時,UIVisualEffectBackdropView變得不透明,它恰好是黑色的。如果您的工具欄是透明的,這似乎會產生一個黑色的工具欄

+1

解決了我的問題。謝謝哥們 – cnu