在Swift 4中使用自定义标签栏控制器时,headerview会转到uinavigation栏的后面

时间:2019-03-22 09:50:57

标签: ios swift uinavigationcontroller uitabbarcontroller

我在iOS应用程序中使用了swift 4的customtabbar控制器,问题是当我登录时,我重定向到其中有两个选项卡的Custom Tabbar控制器,但是我在第一个选项卡中的顶部uiview落后于状态栏,当我单击第二个选项卡,然后一切正常。

func setupTabBar() {
    let storyboard = UIStoryboard.init(name: "Dashboard", bundle: nil)
    let navOne = storyboard.instantiateViewController(withIdentifier: "DashboardNewVCNAV")
    navOne.title = ""
    navOne.tabBarItem.image = UIImage(named: "box_icon")?.withRenderingMode(.alwaysOriginal)
    let vc4 = storyboard.instantiateViewController(withIdentifier: "favoritenav")
    vc4.title = ""
    vc4.tabBarItem.image = UIImage(named: "valentines-heart")?.withRenderingMode(.alwaysOriginal)
    viewControllers = [navOne, vc4]

    guard let items = tabBar.items else { return }

    for item in items {
        item.imageInsets = UIEdgeInsetsMake(4, 0, -4, 0)
    }
}

这是我的自定义标签栏代码,下面是登录成功代码后的

let vc = storyboard.instantiateViewController(withIdentifier: "CustomTabBarController") as! CustomTabBarController
                let appDelegate = UIApplication.shared.delegate as! AppDelegate
                appDelegate.window?.rootViewController = vc

https://prnt.sc/n1dqbf

0 个答案:

没有答案