Chaudhry Talha
Chaudhry Talha

Reputation: 7918

XLPagerTabStrip Squeezed ButtonBarView in Swift 4

I've just recently updated my code to swift 4 and I was using XLPagerTabStrip and this happened:

enter image description here

I referred to this article when I was implementing this and it was working great till Swift 3.2. It's a collection view and I'm using autoresizing for the UI not auto layouts. My code is the same as given in the article so that is why I'm not sharing any.

It has something to do with the layouts but I've tried manual and via code too.

Upvotes: 1

Views: 818

Answers (1)

Joseph Francis
Joseph Francis

Reputation: 1231

You can simply solve this problem by providing size for each cell.

In your parent view controller, put this code:

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {

    return CGSize(width: 120 height: 40)
}

Make sure you set the buttonBarView delegate to self

buttonBarView.delegate = self

Let me know if this helped you.

Upvotes: 1

Related Questions