Xlpagertabstrip: ButtonBarPagerTabStripViewController selectedBarBackgroundColor won't change

Created on 23 Oct 2016  路  13Comments  路  Source: xmartlabs/XLPagerTabStrip

Hello,
Here's my code:
`
override func viewDidLoad() {
buttonBarView.backgroundColor = .white
settings.style.buttonBarBackgroundColor = .white
settings.style.buttonBarItemBackgroundColor = .white
settings.style.buttonBarItemTitleColor = UIColor(netHex: 0x8c8c8c)
settings.style.selectedBarBackgroundColor = UIColor.black
settings.style.selectedBarHeight = 5
super.viewDidLoad()
}

`

Every option of these is working fine apart from selectedBarBackgroundColor which won't get applied as you see here, I've created the buttonBarView as explained in issue #253
simulator screen shot oct 23 2016 1 46 46 pm
Not sure if I'm doing something wrong, any help would be appreciated. Thanks in advance.

Most helpful comment

If you want to use autolayout, see this issue:
https://github.com/xmartlabs/XLPagerTabStrip/issues/229

The solution:
after ViewDidLoad

add below code , it works to me

self.view.layoutIfNeeded()
buttonBarView.selectedBar.frame.origin.y = buttonBarView.frame.size.height - settings.style.selectedBarHeight

All 13 comments

simulator screen shot oct 23 2016 2 00 54 pm
It's not working in the example as well.

I think you need some space for selectedbar.

In my case, I have space with buttonbarview and container view

like this,

image

If i want to help

Thanks for your help, unfortunately this did not make the selected bar appear.

if i can see your code and storyboard,
i can more help to you.

screen shot 2016-10-24 at 3 12 26 pm
screen shot 2016-10-24 at 3 12 41 pm
screen shot 2016-10-24 at 3 13 01 pm
screen shot 2016-10-24 at 3 13 07 pm

Here's everything, thanks for your interest.

I think you need more space for selectedbar
and it seem to use the constraints.
have a control the space! ^^

I added enough space between buttonBarView and containerView (around 100px) and it still changed nothing.

can you make new git??
if you make new git project and sharing to me.
i can check the problem

If you'd share your code for this controller and screenshots of the storyboard that'd be easier, thanks man.

I am also facing the same issue. Creating a constraint of Empty space in between the buttonBarView and my Container did not ending up showing the selected bar.

UPDATE
selectedBar appears if you clear the controller's constrains (keep it without constrains)
Waiting for a fix.

If you want to use autolayout, see this issue:
https://github.com/xmartlabs/XLPagerTabStrip/issues/229

The solution:
after ViewDidLoad

add below code , it works to me

self.view.layoutIfNeeded()
buttonBarView.selectedBar.frame.origin.y = buttonBarView.frame.size.height - settings.style.selectedBarHeight

Worked fine, thank you so much.

Was this page helpful?
0 / 5 - 0 ratings