iosswiftswift4xlpagertabstrip

XLPagerTabStrip Button Bar width wider than navigation bar


I am implementing a ButtonBarPagerTabStripViewController with two buttons on my navigation controller's navigation bar. I followed the example provided by adding the following into viewDidLoad()

self.buttonBarView.backgroundColor = UIColor.clear
self.settings.style.buttonBarItemsShouldFillAvailableWidth = true
self.buttonBarView.removeFromSuperview()
self.navigationController?.navigationBar.addSubview(buttonBarView)

However when the Button Bar loads in the navigation bar the width of the Button Bar exceeds the width of the navigation bar. This leaves me with the following:

navbar image

How can I fix this so that all the buttons fill the width of the navigation bar but do not exceed the width of the navigation bar?


Solution

  • Connecting the containerView outlet to a UIScrollView in Interface Builder fixed this problem for me.