iosswiftxlpagertabstrip

How can I have center the selected tab with XLPagerTabStrip?


I want to have a viewpager having 5 tabs. Max. 3 should be visible at a time, having equal widths and it should center the selected tab. It would be like Fotmob's app screen.

The layout would be like this:

Yesterday | Live| Today | Tomorrow | Day after Tomorrow

How can I achieve this with XLPagerTabStrip?


Solution

  • Set buttonBarLeftContentInset and buttonBarRightContentInset in settings.style to a high value, that will center the selected item.

    settings.style.buttonBarLeftContentInset = 9999
    settings.style.buttonBarRightContentInset = 9999
    

    Sadly, there is no easy way to set up the maximum visibility count with XLPagerTabStrip. You can try to set different values (considering the screen/font size) for settings.style.buttonBarMinimumInteritemSpacing.