Xlpagertabstrip: How to make custom ButtonBarViewCell?

Created on 24 May 2017  路  4Comments  路  Source: xmartlabs/XLPagerTabStrip

Hi, I have the following case, I need to add a label in one of the tabs (which should be placed above the title label) with the number of requests (for example, +9). I made a class inheriting from ButtonBarViewCell, but the changes do not occur. How can I make it? Thanks.

class FriendsPagerViewController: ButtonBarPagerTabStripViewController {

    /// MARK: - Data


    // MARK: - Lifecycle

    override func viewDidLoad() {
        // change selected bar color
        settings.style.buttonBarBackgroundColor = .white
        settings.style.buttonBarItemBackgroundColor = .white
        settings.style.selectedBarBackgroundColor = ColorManager.mainOrange
        let fontManager = FontManager()
        settings.style.buttonBarItemFont = fontManager.font(.RobotoCondensed_Regular, size: 16) ?? .boldSystemFont(ofSize: 14)
        settings.style.selectedBarHeight = 2.0
        settings.style.buttonBarMinimumLineSpacing = 0
        settings.style.buttonBarItemTitleColor = .black
        settings.style.buttonBarItemsShouldFillAvailableWidth = true
        settings.style.buttonBarLeftContentInset = 0
        settings.style.buttonBarRightContentInset = 0

        changeCurrentIndexProgressive = { (oldCell: FriendsButtonBarViewCell?, newCell: FriendsButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in
            guard changeCurrentIndex == true else { return }
            oldCell?.label.textColor = .black
            newCell?.label.textColor = ColorManager.mainOrange
        } as? ((ButtonBarViewCell?, ButtonBarViewCell?, CGFloat, Bool, Bool) -> Void)

        containerView?.isScrollEnabled = false
        super.viewDidLoad()
    }
}

page

awaiting response

Most helpful comment

Hi @alexsanderkhitev

There is no way to set a subclass of ButtonBarViewCell to a ButtonBarPagerTabStripViewController. In order to provide a custom cell, the ButtonBarPagerTabStripViewController exists

In order to use your custom cell for the ButtonBarPagerTabStripViewController, you should be inheriting from BaseButtonBarPagerTabStripViewController<ButtonBarCellType : UICollectionViewCell>. The ButtonBarCellType would be your custom cell. You'll have to override some especific methods, such as func configure to configure the cell.

Please check the YoutubeExampleViewController in the example project to check out more in deep how it is implemented.

Hope it helps! Regards,

All 4 comments

I am encountering the same issue.

Hi @alexsanderkhitev

There is no way to set a subclass of ButtonBarViewCell to a ButtonBarPagerTabStripViewController. In order to provide a custom cell, the ButtonBarPagerTabStripViewController exists

In order to use your custom cell for the ButtonBarPagerTabStripViewController, you should be inheriting from BaseButtonBarPagerTabStripViewController<ButtonBarCellType : UICollectionViewCell>. The ButtonBarCellType would be your custom cell. You'll have to override some especific methods, such as func configure to configure the cell.

Please check the YoutubeExampleViewController in the example project to check out more in deep how it is implemented.

Hope it helps! Regards,

Hi @fedeojeda95

Thank you so much for your response!

Hi @alexsanderkhitev

There is no way to set a subclass of ButtonBarViewCell to a ButtonBarPagerTabStripViewController. In order to provide a custom cell, the ButtonBarPagerTabStripViewController exists

In order to use your custom cell for the ButtonBarPagerTabStripViewController, you should be inheriting from BaseButtonBarPagerTabStripViewController<ButtonBarCellType : UICollectionViewCell>. The ButtonBarCellType would be your custom cell. You'll have to override some especific methods, such as func configure to configure the cell.

Please check the YoutubeExampleViewController in the example project to check out more in deep how it is implemented.

Hope it helps! Regards,

Hi, After inheriting from BaseButtonBarPagerTabStripViewController, but in storyboard i was unable to create IBOutlet . How should I do that?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Emasoft picture Emasoft  路  5Comments

fenixsolorzano picture fenixsolorzano  路  4Comments

SwiftyGuerrero picture SwiftyGuerrero  路  6Comments

dowhilenet picture dowhilenet  路  4Comments

JorgeAGomez picture JorgeAGomez  路  4Comments