2016-09-19 115 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