Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

different indicatorColor for each page #238

Closed
mikle94 opened this issue Aug 22, 2018 · 1 comment
Closed

different indicatorColor for each page #238

mikle94 opened this issue Aug 22, 2018 · 1 comment

Comments

@mikle94
Copy link

mikle94 commented Aug 22, 2018

Hello, I'm trying to change indicatorColor when pagingViewController didScrollToItem, but it doesn't work, it applies color from previous page. So I need to refresh it somehow. Here is what I've tried:

    private func setupView() {
        pagingViewController = PagingViewController<MenuItem>()
        pagingViewController.menuItemSource = .class(type: MenuItemPage.self)
        pagingViewController.menuItemSize = .fixed(width: UIScreen.main.bounds.width / CGFloat(menuItems.count), height: 87)
        pagingViewController.menuItemSpacing = 0
        pagingViewController.menuInsets = .zero
        pagingViewController.borderColor = .clear
        pagingViewController.indicatorColor = menuItems[0].color
        pagingViewController.indicatorClass = MenuIndicator.self
        pagingViewController.indicatorOptions = .visible(
            height: 3,
            zIndex: Int.max,
            spacing: .zero,
            insets: .zero
        )
        pagingViewController.borderOptions = .hidden
        addChildViewController(pagingViewController)
        view.addSubview(pagingViewController.view)
        view.constrainToEdges(pagingViewController.view)
        pagingViewController.didMove(toParentViewController: self)
        pagingViewController.dataSource = self
        pagingViewController.delegate = self
        pagingViewController.select(pagingItem: menuItems[0])
    }
func pagingViewController<T>(_ pagingViewController: PagingViewController<T>, didScrollToItem pagingItem: T, startingViewController: UIViewController?, destinationViewController: UIViewController, transitionSuccessful: Bool) where T : PagingItem, T : Comparable, T : Hashable {
    guard let item = pagingItem as? MenuItem else { return }
    pagingViewController.indicatorColor = item.color
}
@rechsteiner
Copy link
Owner

Hi!

Pushed a fix now that should update the indicator when changing the options #245. Can you target the master branch and see if it works for you now? 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants