我尝试通过使用链接中的meterial来自定义选项卡:https://material.io/components/tabs/ios#using-选项卡
我确实遵循了这个链接中的示例说明,但选项卡没有出现。
这张照片是我想要的选项卡在此处输入图像描述
这是我的代码
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.
}
我的结果:
在此处输入图像描述
您应该给它一个框架或设置约束
tabBarView.frame = CGRext(x:0,y:200,320,50)
view.addSubview(tabBarView)