我的根视图控制器是一个带有 2 个选项卡和一个 MDCAppBar 的 UITabBarController。故事板上的设计看起来很好,两个标签放在相等的两半。但是,当我运行应用程序时,2 个选项卡会出现压缩。我已经尝试了很多事情,但无法解决这个问题。任何帮助/建议表示赞赏。请参阅下面的代码和屏幕截图:
根视图控制器代码:
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) {
}
}