简体   繁体   English

为什么我从 MDCTabBarView() 创建的 Tabbar 没有出现?

[英]Why Tabbar that I create from MDCTabBarView() is not appear?

I try to custom tabbar by using meterial from link: https://material.io/components/tabs/ios#using-tabs我尝试使用来自链接的材料来自定义标签栏: https://material.io/components/tabs/ios#using-tabs

I do follow example instruction in this link but tabbar is not appear.我确实按照此链接中的示例说明进行操作,但未出现标签栏。

This picture is tabbar that I want enter image description here这张图片是标签栏,我想在这里输入图片描述

This is my code这是我的代码

override func viewDidLoad() {
    super.viewDidLoad()
    
    let tabBarView = MDCTabBarView()
    tabBarView.items = [
      UITabBarItem(title: "Recents", image: UIImage(named: "phone"), tag: 0),
      UITabBarItem(title: "Favorites", image: UIImage(named: "heart"), tag: 0),
    ]
    tabBarView.preferredLayoutStyle = .scrollable // or .fixed
    view.addSubview(tabBarView)
    // Configure constraints

    // Do any additional setup after loading the view.
}

My result:我的结果:

enter image description here在此处输入图像描述

You should give it a frame or set constraints你应该给它一个框架或设置约束

tabBarView.frame = CGRext(x:0,y:200,320,50)
view.addSubview(tabBarView)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM