gpt4 book ai didi

ios - 结合 MDCAppBar 和 UITabBarController

转载 作者:行者123 更新时间:2023-11-29 00:10:02 26 4
gpt4 key购买 nike

我的 Root View Controller 是一个带有 2 个选项卡和一个 MDCAppBar 的 UITabBarController。该设计在 Storyboard上看起来很好,两个选项卡均等放置。但是,当我运行该应用程序时,2 个选项卡显示为压缩状态。我已经尝试了很多事情,但无法解决这个问题。任何帮助/建议表示赞赏。请参阅下面的代码和屏幕截图:

Root View Controller 代码:

class BeenstaqTabBarViewController: UITabBarController {

override func viewDidLoad() {
super.viewDidLoad()

let delegate = UIApplication.shared.delegate as! AppDelegate
let appBar = delegate.appBar

addChildViewController(appBar.headerViewController)
appBar.headerViewController.headerView.backgroundColor = MDCPalette.lightBlue.tint800
appBar.navigationBar.tintColor = UIColor.white
appBar.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white,
NSFontAttributeName: UIFont(name: "Roboto-Light", size: 24)!]
appBar.addSubviewsToParent()
title = "beenstaq"

let rightNavIcon = UIImage (named: "Settings")
navigationItem.rightBarButtonItem = UIBarButtonItem(image: rightNavIcon,
style: .plain,
target: self,
action: #selector(barButtonDidTap(_:)))

let leftNavIcon = UIImage (named: "ic_add_circle_outline_white")
navigationItem.leftBarButtonItem = UIBarButtonItem(image: leftNavIcon,
style: .plain,
target: self,
action: #selector(barButtonDidTap(_:)))

}

func barButtonDidTap(_ sender: UIBarButtonItem) {
}

}

主 Storyboard截图: enter image description here

我运行该应用程序时的屏幕截图: enter image description here

最佳答案

如果没有看到更多的项目验证您的选项卡栏约束是否正确配置,很难说这里发生了什么。标签栏应扩展其宽度以匹配其容器的宽度。

除此之外,将示例项目发布到提交于 https://github.com/material-components/material-components-ios/issues/new 的错误中可能会有所帮助

关于ios - 结合 MDCAppBar 和 UITabBarController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46748026/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com