【问题标题】:Get The Phone TabBar Size without any TabBar获取没有任何 TabBar 的电话 TabBar 大小
【发布时间】:2019-05-07 09:30:26
【问题描述】:

我想获得标签栏的默认大小,但我在 ViewController 中没有任何标签栏,所以我没有得到 self.tabBarController?.tabBar.frame.size.height

我在哪里使用:

我有一个容器视图(它使用ViewController 创建),它包含一个collectionview。我想给出一个footer 高度,因为主ViewController 有一个tabBar,所以我必须给出一个高度与tabBar size 一样多。

【问题讨论】:

    标签: ios swift xcode uicollectionview


    【解决方案1】:

    您可以从主 VC 中获取 tabbar 的大小并将其保存到某个全局变量中,然后您可以在应用程序的任何位置使用它。

    【讨论】:

      【解决方案2】:

      如果 tabBarController 是你的根视图控制器,那么:

      let rootController = self.view.window?.rootViewController as! UITabBarController  // Main ViewController  
      let height = rootController?.tabBar.frame.size.height
      

      【讨论】:

        猜你喜欢
        • 2012-10-05
        • 2020-09-24
        • 2020-10-27
        • 2018-11-09
        • 1970-01-01
        • 2020-05-04
        • 2021-09-10
        • 2015-10-07
        • 2021-03-25
        相关资源
        最近更新 更多