0

My root view controller is a UITabBarController with 2 tabs and an MDCAppBar. The design looks just fine on the story board with the 2 tabs placed in equal halves. However when I run the application the 2 tabs appear compressed. I have tried many things but am unable to resolve this. Any help / advice is appreciated. Please see code and screenshots below:

Code of 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) {
    }

}

Screenshot of Main Storyboard: enter image description here

Screenshot of what it looks like when I am running the app: enter image description here

ChicagoSky
  • 1,290
  • 3
  • 22
  • 50

1 Answers1

1

It's difficult to say what's going on here without seeing more of the project verify that your tab bar constraints are configured correctly. The tab bar should be expanding its width to match the width of its container.

Barring that being the issue, it can be helpful to post an example project to a bug filed at https://github.com/material-components/material-components-ios/issues/new

featherless
  • 2,118
  • 19
  • 19